API ตรวจสอบเช็คเลขบัตรประจำตัวประชาชน ทำไว้ให้ service อื่นๆ ภายในระบบ call มาตรวจสอบเลขบัตรประจำตัวประชาชน
This commit is contained in:
parent
a813d31df9
commit
586331e870
2 changed files with 28 additions and 5 deletions
|
|
@ -251,8 +251,11 @@ class Extension {
|
|||
|
||||
public static CheckCitizen(value: string) {
|
||||
let citizen = value;
|
||||
if (citizen == null || citizen == "") {
|
||||
return citizen;
|
||||
if (citizen == null || citizen == "" || citizen == undefined) {
|
||||
throw new HttpError(
|
||||
HttpStatus.NOT_FOUND,
|
||||
"กรุณากรอกข้อมูลรหัสบัตรประจำตัวประชาชน",
|
||||
);
|
||||
}
|
||||
if (citizen.length !== 13) {
|
||||
throw new HttpError(
|
||||
|
|
@ -277,9 +280,12 @@ class Extension {
|
|||
const calStp2 = cal % 11;
|
||||
const chkDigit = (11 - calStp2) % 10;
|
||||
|
||||
// if (citizenIdDigits[12] !== chkDigit) {
|
||||
// throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");
|
||||
// }
|
||||
if (citizenIdDigits[12] !== chkDigit) {
|
||||
throw new HttpError(
|
||||
HttpStatus.NOT_FOUND,
|
||||
"ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง"
|
||||
);
|
||||
}
|
||||
return citizen;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue