ekyc

Electronic KYC process with uploading ID document using OAuth 2.1 (experimental)
Log | Files | Refs | README | LICENSE

code.ts (390B)


      1 import { CODE_REGEX } from "#core/domain/constants.ts";
      2 import { DomainError } from "#core/domain/error.ts";
      3 
      4 export class Code {
      5   constructor(readonly value: string) {
      6     if (!CODE_REGEX.test(value)) {
      7       throw new InvalidCode();
      8     }
      9   }
     10 
     11   toString() {
     12     return this.value;
     13   }
     14 }
     15 
     16 export class InvalidCode extends DomainError {
     17   constructor() {
     18     super("Invalid code");
     19   }
     20 }