@dwp/govuk-casa
Version:
A framework for building GOVUK Collect-And-Submit-Applications
40 lines (39 loc) • 1.21 kB
TypeScript
/**
* @typedef {import("../../casa").ErrorMessageConfig} ErrorMessageConfig
* @access private
*/
/**
* @typedef {object} ArrayConfigOptions
* @property {ErrorMessageConfig} errorMsg Error message config
* @property {string[]} source Array of values to test against
*/
/**
* Test if a value is present in an array.
*
* If the value itself is an array, all values within that array must be present
* in the `source` array in order to pass validation.
*
* See {@link ArrayConfigOptions} for `make()` options.
*
* @memberof Validators
* @augments ValidatorFactory
*/
export default class InArray extends ValidatorFactory {
/** @property {string} name Validator name ("inArray") */
name: string;
validate(value: any, dataContext?: {}): ValidationError[];
sanitise(value: any): string | string[] | undefined;
}
export type ErrorMessageConfig = import("../../casa").ErrorMessageConfig;
export type ArrayConfigOptions = {
/**
* Error message config
*/
errorMsg: ErrorMessageConfig;
/**
* Array of values to test against
*/
source: string[];
};
import ValidatorFactory from "../ValidatorFactory.js";
import ValidationError from "../ValidationError.js";