import { FormControl } from '@angular/forms'; export interface IAtValidatorError { type: string; valid: boolean; value: any; msg: string; } export interface IAtValidatorDate { format: 'mm/dd/yyyy' | 'dd/mm/yyyy' | 'yyyy/mm/dd' | 'mm-dd-yyyy' | 'dd-mm-yyyy' | 'yyyy-mm-dd' | 'mm.dd.yyyy' | 'dd.mm.yyyy' | 'yyyy.mm.dd'; min?: string | Date; max?: string | Date; } export interface IAtValidatorTime { format: '12h' | '24h'; min?: string; max?: string; } export interface IAtValidatorErrMsg { incorrectFormat?: string; invalidData?: string; min?: string; max?: string; } export declare class AtValidators { static SHIFT_CHARACTERS: string; static PUNCTUATION_CHARACTERS: string; static CURRENCY_CHARACTERS: string; static MATH_CHARACTERS: string; /** * Validator that requires controls to have a non-empty value * @param msg Error message. Use %fieldLabel%, %fieldValue% as replacement pattern in error message. * @returns null|{atValidatorsRequired: IAtValidatorError} */ static required(msg?: string): (control: FormControl) => { atValidatorsRequired: IAtValidatorError; }; /** * Validator that requires controls to have a value of a minimum length. * @param length Minimum length of field value. * @param msg Error message. Use %fieldLabel%, %fieldValue% and %length% as replacement pattern in error message. * @returns null|{atValidatorsRequired: IAtValidatorError} */ static minLength(length: number, msg?: string): (control: FormControl) => { atValidatorsExactLength: IAtValidatorError; }; /** * Validator that requires controls to have a value of a maximum length. * @param length Minimum length of field value. * @param msg Error message. Use %fieldLabel%, %fieldValue% and %length% as replacement pattern in error message. * @returns null|{atValidatorsRequired: IAtValidatorError} */ static maxLength(length: number, msg?: string): (control: FormControl) => { atValidatorsExactLength: IAtValidatorError; }; /** * Validator that requires controls to have a value of an exact length. * @param length Length of field. * @param msg Error message. Use %fieldLabel%, %fieldValue% and %length% as replacement pattern in error message. * @returns null|{atValidatorsRequired: IAtValidatorError} */ static exactLength(length: number, msg?: string): (control: FormControl) => { atValidatorsExactLength: IAtValidatorError; }; /** * Validator that requires controls to have a value between a minimum and maximun length. * @param min Minimum value. * @param max Maximum value. * @param msg Error message. Use %fieldLabel%, %fieldValue% and %length% as replacement pattern in error message. * @returns null|{atValidatorsRequired: IAtValidatorError} */ static rangeLength(min: number, max: number, msg?: string): (control: FormControl) => { atValidatorsRangeLength: IAtValidatorError; }; /** * Validator that requires controls to have a numerical value. * @param type The number type. Allows 'int' | 'unsignedInt' | 'float'. Defaults to 'float' * @param msg Error message. Use %fieldLabel%, %fieldValue% and %length% as replacement pattern in error message. * @returns null|{atValidatorsRequired: IAtValidatorError} */ static number(type?: 'int' | 'unsignedInt' | 'float', msg?: string | null): (control: FormControl) => { atValidatorsNumber: IAtValidatorError; }; /** * Validator that requires controls to have a minimun value. * @param value The value to compare * @param msg Error message. Use %fieldLabel%, %fieldValue% and %length% as replacement pattern in error message. * @returns null|{atValidatorsRequired: IAtValidatorError} */ static min(value: number, msg?: string): (control: FormControl) => { atValidatorsMin: IAtValidatorError; }; /** * Validator that requires controls to have a maximun value. * @param value The value to compare * @param msg Error message. Use %fieldLabel%, %fieldValue% and %length% as replacement pattern in error message. * @returns null|{atValidatorsRequired: IAtValidatorError} * @dynamic */ static max(value: number, msg?: string): (control: FormControl) => { atValidatorsMax: IAtValidatorError; }; /** * Validator that requires controls to have a value in a range. * @param min The minimum value * @param max The maximum value * @param msg Error message. Use %fieldLabel%, %fieldValue% and %min% as replacement pattern in error message. * @returns null|{atValidatorsRequired: IAtValidatorError} * @dynamic */ static range(min: number, max: number, msg?: string): (control: FormControl) => { atValidatorsRange: { type: string; valid: boolean; value: any; msg: string; }; }; /** * Validator that requires controls to have an alphanumeric value. * @param allow By default this validator only allows numbers and letters. Use this parameter to allow more characters. * @param msg Error message. Use %fieldLabel%, %fieldValue% and %allow% as replacement pattern in error message. * @returns null|{atValidatorsRequired: IAtValidatorError} * @dynamic */ static alphanumeric(allow?: string | null, msg?: string): (control: FormControl) => { atValidatorsAlphanumeric: { type: string; valid: boolean; value: any; msg: string; }; }; /** * Validator that requires controls to have a correct date value. * @param restrict Restrict field value to a specific format min and max date * @param msg Use %fieldLabel%, %fieldValue% %min% and %max% as replacement pattern in error message. * @returns null|{atValidatorsRequired: IAtValidatorError} * @dynamic */ static date(restrict: IAtValidatorDate, msg?: IAtValidatorErrMsg): (control: FormControl) => { atValidatorsDate: { type: string; valid: boolean; value: any; msg: string; }; }; /** * Validator that requires controls to have a correct time value. * @param restrict Restrict field value to a specific format min and max time * @param msg Use %fieldLabel%, %fieldValue% %min% and %max% as replacement pattern in error message. * @returns null if is valid, IAtValidatorError otherwise */ static time(restrict: IAtValidatorTime, msg?: IAtValidatorErrMsg): (control: FormControl) => { atValidatorsDate: { type: string; valid: boolean; value: any; msg: string; }; } | { atValidatorsTime: { type: string; valid: boolean; value: any; msg: string; }; }; /** * Validator that performs URL validation. * @param msg Error message. Use %fieldLabel% and %fieldValue% as replacement pattern in error message. * @returns null|{atValidatorsRequired: IAtValidatorError} * @dynamic */ static url(msg?: string): (control: FormControl) => { atValidatorsUrl: { type: string; valid: boolean; value: any; msg: string; }; }; /** * Validator that performs Email validation. * @param msg Error message. Use %fieldLabel% and %fieldValue% as replacement pattern in error message. * @returns null|{atValidatorsRequired: IAtValidatorError} * @dynamic */ static email(msg?: string): (control: FormControl) => { atValidatorsEmail: { type: string; valid: boolean; value: any; msg: string; }; }; /** * Validator that check if current form field matches other field. * @param otherFieldName the name of the other field inside the form group. * @param msg Error message. Use %fieldLabel%, %fieldValue%, %otherFieldName% and %otherFieldLabel% as replacement pattern in error message. * @returns null|{atValidatorsRequired: IAtValidatorError} * @dynamic */ static matchOtherField(otherFieldName: string, otherFieldLabel: string, msg?: string): (control: FormControl) => { atValidatorsMatchOtherField: { type: string; valid: boolean; value: any; msg: string; }; }; /** * Validator that requires controls to exclude certain characters. * @param msg Error message. Use %fieldLabel%, %fieldValue% and %characters% as replacement pattern in error message. * @returns null|{atValidatorsRequired: IAtValidatorError} * @dynamic */ static exclude(characters?: string | null, msg?: string): (control: FormControl) => { atValidatorsAlphanumeric: { type: string; valid: boolean; value: any; msg: string; }; }; /** * Validator that requires controls to include at least one characters. * @param msg Error message. Use %fieldLabel%, %fieldValue% and %characters% as replacement pattern in error message. * @returns null|{atValidatorsRequired: IAtValidatorError} * @dynamic */ static include(characters?: string | null, msg?: string): (control: FormControl) => { atValidatorsRejectOnly: { type: string; valid: boolean; value: any; msg: string; }; }; /** * Validator that requires a control to match a regex to its value. * @param msg Error message. Use %fieldLabel% and %fieldValue% as replacement pattern in error message. * @returns null|{atValidatorsRequired: IAtValidatorError} * @dynamic */ static regExp(regexp: RegExp, msg?: string): (control: FormControl) => { atValidatorsRegExp: { type: string; valid: boolean; value: any; msg: string; }; }; /** * Validator that uses a custom function to check if FormControl is valid. * @param (formCtrl: FormControl) => string fn Function that returns an string if formCtrl is invalid and null otherwise. * The returned string will be used as an error message, you can use %fieldLabel% and %fieldValue% as replacement pattern in error message. * @returns null|{atValidatorsRequired: IAtValidatorError} * @dynamic */ static custom(fn: (formCtrl: FormControl) => (string | null)): (control: FormControl) => { atValidatorsCustom: { type: string; valid: boolean; value: any; msg: string; }; }; }