Validator

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

© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v2.angular.io/docs/ts/latest/api/forms/index/Validator-interface.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部