Validator

Stable Interface

Interface Overview

interface Validator {
  validate(c: AbstractControl) : {[key: string]: any}
  registerOnValidatorChange(fn: () => void) : void
}

Interface Description

An interface that can be implemented by classes that can act as validators.

Usage

@Directive({
  selector: '[custom-validator]',
  providers: [{provide: NG_VALIDATORS, useExisting: CustomValidatorDirective, multi: true}]
})
class CustomValidatorDirective implements Validator {
  validate(c: Control): {[key: string]: any} {
    return {"custom": true};
  }
}

Interface Details

validate(c: AbstractControl) : {[key: string]: any}
registerOnValidatorChange(fn: () => void) : void

exported from @angular/forms/index, defined in @angular/forms/src/directives/validators.ts

doc_Angular
2016-10-06 09:47:11
Comments
Leave a Comment

Please login to continue.