style(forms): reformat of the forms package after clang update (#36466)

PR Close #36466
This commit is contained in:
Andrew Kushnir
2020-04-06 15:44:00 -07:00
committed by Kara Erickson
parent 416c786774
commit 7d0af179e3
37 changed files with 5410 additions and 5093 deletions

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Directive, Input, OnChanges, SimpleChanges, StaticProvider, forwardRef} from '@angular/core';
import {Directive, forwardRef, Input, OnChanges, SimpleChanges, StaticProvider} from '@angular/core';
import {Observable} from 'rxjs';
import {AbstractControl} from '../model';
@ -136,11 +136,11 @@ export const CHECKBOX_REQUIRED_VALIDATOR: StaticProvider = {
* @description
* A directive that adds the `required` validator to any controls marked with the
* `required` attribute. The directive is provided with the `NG_VALIDATORS` multi-provider list.
*
*
* @see [Form Validation](guide/form-validation)
*
* @usageNotes
*
*
* ### Adding a required validator using template-driven forms
*
* ```
@ -159,16 +159,18 @@ export const CHECKBOX_REQUIRED_VALIDATOR: StaticProvider = {
})
export class RequiredValidator implements Validator {
// TODO(issue/24571): remove '!'.
private _required !: boolean;
private _required!: boolean;
// TODO(issue/24571): remove '!'.
private _onChange !: () => void;
private _onChange!: () => void;
/**
* @description
* Tracks changes to the required attribute bound to this directive.
*/
@Input()
get required(): boolean|string { return this._required; }
get required(): boolean|string {
return this._required;
}
set required(value: boolean|string) {
this._required = value != null && value !== false && `${value}` !== 'false';
@ -190,22 +192,25 @@ export class RequiredValidator implements Validator {
*
* @param fn The callback function
*/
registerOnValidatorChange(fn: () => void): void { this._onChange = fn; }
registerOnValidatorChange(fn: () => void): void {
this._onChange = fn;
}
}
/**
* A Directive that adds the `required` validator to checkbox controls marked with the
* `required` attribute. The directive is provided with the `NG_VALIDATORS` multi-provider list.
*
*
* @see [Form Validation](guide/form-validation)
*
* @usageNotes
*
*
* ### Adding a required checkbox validator using template-driven forms
*
* The following example shows how to add a checkbox required validator to an input attached to an ngModel binding.
*
* The following example shows how to add a checkbox required validator to an input attached to an
* ngModel binding.
*
* ```
* <input type="checkbox" name="active" ngModel required>
* ```
@ -248,11 +253,12 @@ export const EMAIL_VALIDATOR: any = {
* @see [Form Validation](guide/form-validation)
*
* @usageNotes
*
*
* ### Adding an email validator
*
* The following example shows how to add an email validator to an input attached to an ngModel binding.
*
* The following example shows how to add an email validator to an input attached to an ngModel
* binding.
*
* ```
* <input type="email" name="email" ngModel email>
* <input type="email" name="email" ngModel email="true">
@ -269,9 +275,9 @@ export const EMAIL_VALIDATOR: any = {
})
export class EmailValidator implements Validator {
// TODO(issue/24571): remove '!'.
private _enabled !: boolean;
private _enabled!: boolean;
// TODO(issue/24571): remove '!'.
private _onChange !: () => void;
private _onChange!: () => void;
/**
* @description
@ -298,7 +304,9 @@ export class EmailValidator implements Validator {
*
* @param fn The callback function
*/
registerOnValidatorChange(fn: () => void): void { this._onChange = fn; }
registerOnValidatorChange(fn: () => void): void {
this._onChange = fn;
}
}
/**
@ -308,7 +316,9 @@ export class EmailValidator implements Validator {
*
* @publicApi
*/
export interface ValidatorFn { (control: AbstractControl): ValidationErrors|null; }
export interface ValidatorFn {
(control: AbstractControl): ValidationErrors|null;
}
/**
* @description
@ -334,7 +344,7 @@ export const MIN_LENGTH_VALIDATOR: any = {
/**
* A directive that adds minimum length validation to controls marked with the
* `minlength` attribute. The directive is provided with the `NG_VALIDATORS` multi-provider list.
*
*
* @see [Form Validation](guide/form-validation)
*
* @usageNotes
@ -357,19 +367,18 @@ export const MIN_LENGTH_VALIDATOR: any = {
providers: [MIN_LENGTH_VALIDATOR],
host: {'[attr.minlength]': 'minlength ? minlength : null'}
})
export class MinLengthValidator implements Validator,
OnChanges {
export class MinLengthValidator implements Validator, OnChanges {
// TODO(issue/24571): remove '!'.
private _validator !: ValidatorFn;
private _validator!: ValidatorFn;
// TODO(issue/24571): remove '!'.
private _onChange !: () => void;
private _onChange!: () => void;
/**
* @description
* Tracks changes to the the minimum length bound to this directive.
*/
// TODO(issue/24571): remove '!'.
@Input() minlength !: string | number;
@Input() minlength!: string|number;
/**
* @description
@ -400,7 +409,9 @@ export class MinLengthValidator implements Validator,
*
* @param fn The callback function
*/
registerOnValidatorChange(fn: () => void): void { this._onChange = fn; }
registerOnValidatorChange(fn: () => void): void {
this._onChange = fn;
}
private _createValidator(): void {
this._validator = Validators.minLength(
@ -421,7 +432,7 @@ export const MAX_LENGTH_VALIDATOR: any = {
/**
* A directive that adds max length validation to controls marked with the
* `maxlength` attribute. The directive is provided with the `NG_VALIDATORS` multi-provider list.
*
*
* @see [Form Validation](guide/form-validation)
*
* @usageNotes
@ -444,19 +455,18 @@ export const MAX_LENGTH_VALIDATOR: any = {
providers: [MAX_LENGTH_VALIDATOR],
host: {'[attr.maxlength]': 'maxlength ? maxlength : null'}
})
export class MaxLengthValidator implements Validator,
OnChanges {
export class MaxLengthValidator implements Validator, OnChanges {
// TODO(issue/24571): remove '!'.
private _validator !: ValidatorFn;
private _validator!: ValidatorFn;
// TODO(issue/24571): remove '!'.
private _onChange !: () => void;
private _onChange!: () => void;
/**
* @description
* Tracks changes to the the maximum length bound to this directive.
*/
// TODO(issue/24571): remove '!'.
@Input() maxlength !: string | number;
@Input() maxlength!: string|number;
/**
* @description
@ -487,7 +497,9 @@ export class MaxLengthValidator implements Validator,
*
* @param fn The callback function
*/
registerOnValidatorChange(fn: () => void): void { this._onChange = fn; }
registerOnValidatorChange(fn: () => void): void {
this._onChange = fn;
}
private _createValidator(): void {
this._validator = Validators.maxLength(
@ -511,7 +523,7 @@ export const PATTERN_VALIDATOR: any = {
* A directive that adds regex pattern validation to controls marked with the
* `pattern` attribute. The regex must match the entire control value.
* The directive is provided with the `NG_VALIDATORS` multi-provider list.
*
*
* @see [Form Validation](guide/form-validation)
*
* @usageNotes
@ -524,7 +536,7 @@ export const PATTERN_VALIDATOR: any = {
* ```html
* <input name="firstName" ngModel pattern="[a-zA-Z ]*">
* ```
*
*
* @ngModule ReactiveFormsModule
* @ngModule FormsModule
* @publicApi
@ -534,19 +546,18 @@ export const PATTERN_VALIDATOR: any = {
providers: [PATTERN_VALIDATOR],
host: {'[attr.pattern]': 'pattern ? pattern : null'}
})
export class PatternValidator implements Validator,
OnChanges {
export class PatternValidator implements Validator, OnChanges {
// TODO(issue/24571): remove '!'.
private _validator !: ValidatorFn;
private _validator!: ValidatorFn;
// TODO(issue/24571): remove '!'.
private _onChange !: () => void;
private _onChange!: () => void;
/**
* @description
* Tracks changes to the pattern bound to this directive.
*/
// TODO(issue/24571): remove '!'.
@Input() pattern !: string | RegExp;
@Input() pattern!: string|RegExp;
/**
* @description
@ -567,7 +578,9 @@ export class PatternValidator implements Validator,
* Method that validates whether the value matches the
* the pattern requirement.
*/
validate(control: AbstractControl): ValidationErrors|null { return this._validator(control); }
validate(control: AbstractControl): ValidationErrors|null {
return this._validator(control);
}
/**
* @description
@ -575,7 +588,11 @@ export class PatternValidator implements Validator,
*
* @param fn The callback function
*/
registerOnValidatorChange(fn: () => void): void { this._onChange = fn; }
registerOnValidatorChange(fn: () => void): void {
this._onChange = fn;
}
private _createValidator(): void { this._validator = Validators.pattern(this.pattern); }
private _createValidator(): void {
this._validator = Validators.pattern(this.pattern);
}
}