-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModules.ts
More file actions
39 lines (32 loc) · 1.12 KB
/
Modules.ts
File metadata and controls
39 lines (32 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
export const numberRegexp = /^[0-9]+$/;
export class ZipCodeValidator {
isAcceptable(s: string) {
return s.length === 5 && numberRegexp.test(s);
}
}
class ZipCodeValidator1 {
isAcceptable(s: string) {
return s.length === 5 && numberRegexp.test(s);
}
}
export { ZipCodeValidator1 };
export { ZipCodeValidator1 as mainValidator };
export class ParseIntBasedZipCodeValidator {
isAcceptable(s: string) {
return s.length === 5 && parseInt(s).toString() === s;
}
}
// Export original validator but rename it
export {
ZipCodeValidator as RegExpBasedZipCodeValidator
} from "./ZipCodeValidator";
export * from "./StringValidator"; // exports interface 'StringValidator'
export * from "./LettersOnlyValidator"; // exports class 'LettersOnlyValidator'
export * from "./ZipCodeValidator"; // exports class 'ZipCodeValidator'
//Import
import { ZipCodeValidator } from "./ZipCodeValidator";
let myValidator = new ZipCodeValidator();
import { ZipCodeValidator as ZCV } from "./ZipCodeValidator";
let myValidator1 = new ZCV();
import * as validator from "./ZipCodeValidator";
let myValidator2 = new validator.ZipCodeValidator();