@porscheinformatik/clr-addons
Version:
Addon components for Clarity Angular
27 lines (26 loc) • 903 B
TypeScript
import { ValidatorFn } from '@angular/forms';
/**
* Class to provide validators for the Clr Data List.
*/
export declare class ClrDataListValidators {
/**
* @description
* Validator that requires the control's value to be found in a possible values array.
* This prohibits the user from entering custom values.
*
* @usageNotes
*
* ### Validate against an array of possible values
*
* ```typescript
* const control = new FormControl('1234', ClrDataListValidators.predefined(['ASDF', 'QWER']));
*
* console.log(control.errors); // {predefined: {predefined: ['ASDF', 'QWER'], actual: '1234'}}
* ```
*
* @returns A validator function that returns an error map with the
* `predefined` property if the validation check fails, otherwise `null`.
*
*/
static predefined(possibleValues: string[]): ValidatorFn;
}