UNPKG

@dwp/govuk-casa

Version:

A framework for building GOVUK Collect-And-Submit-Applications

86 lines (85 loc) 2.83 kB
/** * @typedef {import("../../casa").ErrorMessageConfig} ErrorMessageConfig * @access private */ /** * @typedef {object} PostalAddressObjectConfigOptions * @property {ErrorMessageConfig} [errorMsg] General error message for the * entire address block * @property {string | object} [errorMsgAddress1] Error message for address1 * part * @property {string | object} [errorMsgAddress2] Error message for address2 * part * @property {string | object} [errorMsgAddress3] Error message for address3 * part * @property {string | object} [errorMsgAddress4] Error message for address4 * part * @property {string | object} [errorMsgPostcode] Error message for postcode * part * @property {number} [strlenmax] Max. String length for each of the inputs * address[1-4] * @property {string[]} [requiredFields] Field parts required (others become * optional). One of 'address1'|'address2'|'address3'|'address4'|'postcode' */ /** * Works hand in hand with the core CASA `postalAddressObject` form macro. * * The errors sent back from this validator are specific to each subfield. For * example, if the field name being tested is "address", any errors related to * the "postcode" component would be associated with "address[postcode]". * * See {@link PostalAddressObjectConfigOptions} for `make()` options. * * @memberof Validators * @augments ValidatorFactory */ export default class PostalAddressObject extends ValidatorFactory { name: string; validate(value: any, dataContext?: {}): ValidationError[]; sanitise(value: any): any; } export type ErrorMessageConfig = import("../../casa").ErrorMessageConfig; export type PostalAddressObjectConfigOptions = { /** * General error message for the * entire address block */ errorMsg?: import("../../casa").ErrorMessageConfig | undefined; /** * Error message for address1 * part */ errorMsgAddress1?: string | object | undefined; /** * Error message for address2 * part */ errorMsgAddress2?: string | object | undefined; /** * Error message for address3 * part */ errorMsgAddress3?: string | object | undefined; /** * Error message for address4 * part */ errorMsgAddress4?: string | object | undefined; /** * Error message for postcode * part */ errorMsgPostcode?: string | object | undefined; /** * Max. String length for each of the inputs * address[1-4] */ strlenmax?: number | undefined; /** * Field parts required (others become * optional). One of 'address1'|'address2'|'address3'|'address4'|'postcode' */ requiredFields?: string[] | undefined; }; import ValidatorFactory from "../ValidatorFactory.js"; import ValidationError from "../ValidationError.js";