import { OnChanges, SimpleChanges } from '@angular/core';
import { AbstractControl, FormControl, ValidatorFn, ValidationErrors, Validator, FormGroup } from '@angular/forms';
/**
* Represents a class that contains a boolean property named `required`.
*/
export interface RequiredProperty {
/**
* Returns true if the control is required; otherwise, false.
*/
readonly required: boolean;
}
/**
* @description
* Provides a set of extra validators that can be used by form controls.
*
* A validator is a function that processes a `FormControl` or collection of
* controls and returns an error map or `null`. A `null` map means that validation has passed.
*
* @see [Form Validation](/guide/form-validation)
*/
export declare class ExtraValidators {
/**
* @description
* Validator that requires the length of the control's value to be equal to the
* provided length. It assumes that the control's value is of string type.
* This validator is used with Reactive Forms; if you want to use
* an equivalent validator with Template-driven Form you must use the `equalLength` attribute.
*
* @usageNotes
*
* ### Validates that the field has a length of 4 characters:
*
* ```typescript
* const control = new FormControl('ng', ExtraValidators.equalLength(4));
*
* console.log(control.errors); // { equalLength: { requiredLength: 4, actualLength: 2 } }
* ```
*
* ```html
*
* ```
*
* @returns A validator function that returns an error map with the `equalLength`
* if the validation check fails, otherwise `null`.
*/
static equalLength(equalLength: number): ValidatorFn;
/**
* @description
* Validator that is applied to `FormArray` controls. It requires that the amount of
* `FormArray`'s child controls to be greater than or equal to the provided minimum length.
* The validator exists only as a function and not as a directive.
*
* @usageNotes
*
* ### Validates that the `FormArray` field has a minimum of 2 child controls:
*
* ```typescript
* const formArrayControl = new FormArray([new FormControl('ng')], ExtraValidators.minLength(2));
*
* console.log(formArrayControl.errors); // { minLength: { requiredLength: 2, actualLength: 1 } }
* ```
*
* @returns A validator function that returns an error map with the
* `minLength` if the validation check fails, otherwise `null`.
*/
static minLength(minLength: number): ValidatorFn;
/**
* @description
* Validator that is applied to a control that has an array of child controls.
* It receives an object that fits the `RequiredProperty` interface and an array of child controls.
* The behavior of the validator is the following:
* If the control's value is required, then
* - all child controls must be different of empty.
* If the control's value is not required, then
* - all child controls can be empty.
* - if there is at least one child control not empty, then all child controls must be different of empty.
* The validator exists only as a function and not as a directive.
*
* @usageNotes
*
* ### Validates that the control does not have an empty child control:
*
* ```typescript
* const control = new FormGroup({
* 'fg': (firstGroup = new FormControl('2049')),
* 'sg': (secondGroup = new FormControl(''))},
* ExtraValidators.requiredAndNotEmpty(this, [firstGroup, secondGroup]));
*
* console.log(control.errors); // { requiredAndNotEmpty: { required: true, pos: 1 } }
* ```
*
* @returns A validator function that returns an error map with the `requiredAndNotEmpty`
* if the validation check fails, otherwise `null`.
*/
static requiredAndNotEmpty(requiredProperty: RequiredProperty, childControls: FormControl[]): ValidatorFn;
/**
* @description
* Validator that requires the control's value pass an ISSN validation test (confirm the check digit).
* Assumes that the code (control's value) is a string of length 11, with the form 'XXXX – XXXX'.
* The validator exists only as a function and not as a directive.
*
* @usageNotes
*
* ### Validates that the field matches a valid ISSN pattern (confirms the check digit):
*
* ```typescript
* const control = new FormControl('2049 – 3635', ExtraValidators.issnConfirmCheckDigitOneField(11));
*
* console.log(control.errors); // { issnConfirmCheckDigitOneField: true }
* ```
*
* @returns A validator function that returns an error map with the `issnConfirmCheckDigitOneField`
* if the validation check fails, otherwise `null`.
*/
static issnConfirmCheckDigitOneField(codeLength: number): ValidatorFn;
/**
* @description
* Validator that requires the control's value passes an ISSN validation test (confirms the check digit).
* The ISSN value is divided in two groups, therefore the control has two child controls and they are
* arguments of the validator method. It assumes that the control's value is of string type.
* The validator exists only as a function and not as a directive.
*
* @usageNotes
*
* ### Validates that the field matches a valid ISSN pattern (confirms the check digit):
*
* ```typescript
* const control = new FormGroup({
* 'fg': (firstGroup = new FormControl('2049')),
* 'sg': (secondGroup = new FormControl('3635'))},
* ExtraValidators.issnConfirmCheckDigitTwoField(firstGroup, secondGroup, 4));
*
* console.log(control.errors); // { issnConfirmCheckDigitTwoField: true }
* ```
*
* @returns A validator function that returns an error map with the `issnConfirmCheckDigitTwoField`
* if the validation check fails, otherwise `null`.
*/
static issnConfirmCheckDigitTwoField(firstGroup: FormControl, secondGroup: FormControl, groupLength: number): ValidatorFn;
static issnValidator(internalFormGroup: FormGroup): ValidatorFn;
}
/**
* @description
* A directive that represents a validator that requires the length of the control's value
* to be equal to the provided length. The control must be marked with the `equalLength` attribute.
* The directive is provided with the `NG_VALIDATORS` mult-provider list.
* This validator is used with Template-driven Form; if you want to use an equivalent validator
* with Reactive Forms you must use the `ExtraValidators.equalLength` method.
*
* @usageNotes
*
* ### Validates that the field has a length of 4 characters:
*
* The following example shows how to add an equal length validator to an input attached to an
* ngModel binding.
*
* ```html
*
* ```
*/
export declare class EqualLengthDirective implements OnChanges, Validator {
/**
* @description
* Input variable that contains the length to check.
*/
equalLength: string;
private _validator;
private _onChange;
/**
* @description
* A lifecycle hook method that is called when the directive's inputs change. For internal use only.
*
* @param changes An object of key/value pairs for the set of changed inputs.
*/
ngOnChanges(changes: SimpleChanges): void;
/**
* @description
* Method that performs synchronous validation against the provided control. It requires the length
* of the control's value to be equal to the provided `equalLength`.
*
* @param control The control to validate against.
*
* @returns A map of validation errors if validation fails; otherwise, `null`.
*/
validate(control: AbstractControl): ValidationErrors | null;
/**
* @description
* Registers a callback function to call when the validator inputs change.
*
* @param fn The callback function to register.
*/
registerOnValidatorChange(fn: () => void): void;
}