36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
|
|
/**
|
||
|
|
* @license
|
||
|
|
* Copyright Google LLC All Rights Reserved.
|
||
|
|
*
|
||
|
|
* Use of this source code is governed by an MIT-style license that can be
|
||
|
|
* found in the LICENSE file at https://angular.dev/license
|
||
|
|
*/
|
||
|
|
|
||
|
|
import {Directive, forwardRef, Provider} from '@angular/core';
|
||
|
|
import {CheckboxRequiredValidator, NG_VALIDATORS} from '@angular/forms';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @deprecated No longer used, `MatCheckbox` implements required validation directly.
|
||
|
|
* @breaking-change 19.0.0
|
||
|
|
*/
|
||
|
|
export const MAT_CHECKBOX_REQUIRED_VALIDATOR: Provider = {
|
||
|
|
provide: NG_VALIDATORS,
|
||
|
|
useExisting: forwardRef(() => MatCheckboxRequiredValidator),
|
||
|
|
multi: true,
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Validator for Material checkbox's required attribute in template-driven checkbox.
|
||
|
|
* Current CheckboxRequiredValidator only work with `input type=checkbox` and does not
|
||
|
|
* work with `mat-checkbox`.
|
||
|
|
*
|
||
|
|
* @deprecated No longer used, `MatCheckbox` implements required validation directly.
|
||
|
|
* @breaking-change 19.0.0
|
||
|
|
*/
|
||
|
|
@Directive({
|
||
|
|
selector: `mat-checkbox[required][formControlName],
|
||
|
|
mat-checkbox[required][formControl], mat-checkbox[required][ngModel]`,
|
||
|
|
providers: [MAT_CHECKBOX_REQUIRED_VALIDATOR],
|
||
|
|
})
|
||
|
|
export class MatCheckboxRequiredValidator extends CheckboxRequiredValidator {}
|