angular-cn/aio/dist/generated/docs/api/forms/NG_VALIDATORS.json

5 lines
5.3 KiB
JSON
Raw Permalink Normal View History

{
"id": "api/forms/NG_VALIDATORS",
"title": "NG_VALIDATORS",
"contents": "\n\n<article>\n <div class=\"breadcrumb-container\">\n <div class=\"breadcrumb\">\n <script type=\"application/ld+json\">\n {\n \"@context\": \"http://schema.org\",\n \"@type\": \"BreadcrumbList\",\n \"itemListElement\": [\n { \"@type\": \"ListItem\", \"position\": 1, \"item\": { \"@id\": \"https://angular.io//api\", \"name\": \"API\" } },\n { \"@type\": \"ListItem\", \"position\": 2, \"item\": { \"@id\": \"https://angular.io/api/forms\", \"name\": \"@angular/forms\" } },\n { \"@type\": \"ListItem\", \"position\": 3, \"item\": { \"@id\": \"https://angular.io/api/forms/NG_VALIDATORS\", \"name\": \"NG_VALIDATORS\" } }\n ]\n }\n </script>\n <a href=\"/api\">API</a> > <a href=\"api/forms\">@angular/forms</a>\n </div>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/forms/src/validators.ts?message=docs(forms)%3A%20describe%20your%20change...#L55-L54\" aria-label=\"Suggest Edits\" title=\"Suggest Edits\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">mode_edit</i></a>\n <a href=\"https://github.com/angular/angular/tree/12.0.0-next.7/packages/forms/src/validators.ts#L55-L54\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n \n <header class=\"api-header\">\n <h1 id=\"ng_validators\">NG_VALIDATORS<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/forms/NG_VALIDATORS#ng_validators\"><i class=\"material-icons\">link</i></a></h1>\n \n <label class=\"api-type-label const\">const</label>\n \n \n \n </header>\n \n <aio-toc class=\"embedded\"></aio-toc>\n\n <div class=\"api-body\">\n \n <section class=\"short-description\">\n <p>An <code><a href=\"api/core/InjectionToken\" class=\"code-anchor\">InjectionToken</a></code> for registering additional synchronous validators used with\n<code><a href=\"api/forms/AbstractControl\" class=\"code-anchor\">AbstractControl</a></code>s.</p>\n\n \n </section>\n \n \n \n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box api-heading\">\n const <a href=\"api/forms/NG_VALIDATORS\" class=\"code-anchor\">NG_VALIDATORS</a>: <a href=\"api/core/InjectionToken\" class=\"code-anchor\">InjectionToken</a>&#x3C;(Function | <a href=\"api/forms/Validator\" class=\"code-anchor\">Validator</a>)[]>;\n </code-example>\n\n \n<section class=\"see-also\">\n <h2 id=\"see-also\">See also<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/forms/NG_VALIDATORS#see-also\"><i class=\"material-icons\">link</i></a></h2>\n <ul>\n \n <li><p><code><a href=\"api/forms/NG_ASYNC_VALIDATORS\" class=\"code-anchor\">NG_ASYNC_VALIDATORS</a></code></p>\n</li>\n </ul>\n</section>\n\n\n \n \n\n \n<section class=\"usage-notes\">\n <h2 id=\"usage-notes\">Usage notes<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/forms/NG_VALIDATORS#usage-notes\"><i class=\"material-icons\">link</i></a></h2>\n <h3 id=\"providing-a-custom-validator\">Providing a custom validator<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/forms/NG_VALIDATORS#providing-a-custom-validator\"><i class=\"material-icons\">link</i></a></h3>\n<p>The following example registers a custom validator directive. Adding the validator to the\nexisting collection of validators requires the <code>multi: true</code> option.</p>\n<code-example language=\"typescript\">\n@<a href=\"api/core/Directive\" class=\"code-anchor\">Directive</a>({\n selector: '[customValidator]',\n providers: [{provide: <a href=\"api/forms/NG_VALIDATORS\" class=\"code-anchor\">NG_VALIDATORS</a>, useExisting: CustomValidatorDirective, multi: true}]\n})\nclass CustomValidatorDirective implements <a href=\"api/forms/Validator\" class=\"code-anchor\">Validator</a> {\n validate(control: <a href=\"api/forms/AbstractControl\" clas
}