Last active
February 3, 2019 22:29
-
-
Save wspringer/df828e5e25aa3b008e817726cccf6127 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let numberRegexp = /^[0-9]+$/; | |
export interface Validator<T> { | |
isAcceptable(t: T): boolean; | |
} | |
export class ZipCodeValidator implements Validator<String> { | |
isAcceptable(s: string) { | |
return s.length === 5 && numberRegexp.test(s); | |
} | |
} | |
(new ZipCodeValidator()).isAcceptable("09800"); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment