UNPKG

@tapsellorg/angular-material-library

Version:

Angular library for Tapsell

80 lines (79 loc) 2.83 kB
import { AbstractControl, ValidatorFn } from '@angular/forms'; export declare class PghFormValidators { private static readonly URL_REGEX; private static readonly ENTITY_REGEX; private static readonly PHONE_NUMBER_REGEX; /** * FormGroup Validator * * ```typescript * this.formBuilder.group({ * password: [], * confirmPassword: [], * }, { * validators: [PghFormValidators.matchPassword] * }) * ``` * * @param passwordField * @param confirmField */ static matchPassword(passwordField: string, confirmField: string): (formGroup: AbstractControl) => { mismatchPassword: boolean; } | undefined; static urlValidator(): ValidatorFn; /** * Validates an android entity. Example: any://any */ static entityValidator(): ValidatorFn; static phoneNumberValidator(): ValidatorFn; /** * Uppercase letters aren't allowed */ static noUppercase(): ValidatorFn; static postalCode(): ValidatorFn; static shaba(includeIR?: boolean): ValidatorFn; static debitCard(): ValidatorFn; /** * Runs the validator only if the condition function returns true * you can optionally include an elseValidator * @param condition * @param validator * @param elseValidator */ static conditionalValidator(condition: () => boolean, validator: ValidatorFn, elseValidator?: ValidatorFn): ValidatorFn; /** * Validates a given condition function is true. If it's not, It'll be invalid with the errorName provided * @param condition * @param errorName */ static validateCondition(condition: (control: AbstractControl) => boolean, errorName: string): ValidatorFn; /** * Validates the value is not any of the given options * @param forbiddenValues */ static forbiddenValues(forbiddenValues: any[]): ValidatorFn; /** * Validates the value is one of the given options * @param allowedValues */ static allowedValues(allowedValues: any[]): ValidatorFn; /** * Same as the angular pattern validator but with a custom errorName. * This is useful when you want to check multiple patterns against a control and * display different error messages for each pattern * @param regex Regex to check * @param errorName a custom error name */ static pattern(regex: RegExp, errorName: string): ValidatorFn; /** * Opposite of the pattern validator * @param regex Regex to check * @param errorName a custom error name */ static forbiddenPattern(regex: RegExp, errorName: string): ValidatorFn; static iranianNationalCode(): ValidatorFn; static hasNumber(): ValidatorFn; static hasCapitalCase(): ValidatorFn; static hasSmallCase(): ValidatorFn; }