Answers for "angular validation"

1

angular validation

class Validators {
  static min(min: number): ValidatorFn
  static max(max: number): ValidatorFn
  static required(control: AbstractControl): ValidationErrors | null
  static requiredTrue(control: AbstractControl): ValidationErrors | null
  static email(control: AbstractControl): ValidationErrors | null
  static minLength(minLength: number): ValidatorFn
  static maxLength(maxLength: number): ValidatorFn
  static pattern(pattern: string | RegExp): ValidatorFn
  static nullValidator(control: AbstractControl): ValidationErrors | null
  static compose(validators: ValidatorFn[]): ValidatorFn | null
  static composeAsync(validators: AsyncValidatorFn[]): AsyncValidatorFn | null
}
Posted by: Guest on August-07-2021
0

custom validator

import {AbstractControl, ValidatorFn} from '@angular/forms';

export function blue(): ValidatorFn {  
    return (control: AbstractControl): { [key: string]: any } | null =>  
        control.value?.toLowerCase() === 'blue' 
            ? null : {wrongColor: control.value};
}
<>
Posted by: Guest on November-27-2020
3

validation minlength angular

Validators.minLength(9)
Posted by: Guest on July-23-2020
2

formgroup check if valid

form: FormGroup;

onSubmit(){
    //checks if form is valid
       if( this.form.valid){
          //more code here
        }
}
Posted by: Guest on July-31-2020
0

angular9+how+to+add+validators

this.form.controls["firstName"].setValidators([Validators.minLength(1), Validators.maxLength(30)]);
Posted by: Guest on June-21-2020
0

angular number validation

ng-pattern="re"
Posted by: Guest on October-16-2020

Code answers related to "angular validation"

Browse Popular Code Answers by Language