aboutsummaryrefslogtreecommitdiffstats
path: root/src/angular/form-elements/validation/validators/custom.validator.component.ts
blob: eb09636b599577ad14ef1b3ba46cd5accd26bf81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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-custom-validator',
    template: template
})
export class CustomValidatorComponent extends ValidatorComponent implements IValidator {

    @Input() public callback: (...args) => boolean;

    constructor() {
        super();
    }

    public validate(value: any): boolean {
        this.isValid = this.callback(value);
        return this.isValid;
    }

}