blob: 5a213a96da791a4f9c80cd6a9b64041434c771f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import { Input, Component } from "@angular/core";
import { ValidatorComponent } from "./base.validator.component";
import { IValidator } from './validator.interface';
import { template } from "./base.validator.component.html";
@Component({
selector: 'sdc-regex-validator',
template: template
})
export class RegexValidatorComponent extends ValidatorComponent implements IValidator {
@Input() public pattern: RegExp;
constructor() {
super();
}
public validate(value: any): boolean {
const regexp = new RegExp(this.pattern);
this.isValid = regexp.test(value);
return this.isValid;
}
}
|