UNPKG

form-associated-helpers

Version:

A collection of reusable mixins + helpers for working with form associated custom elements.

19 lines (18 loc) 699 B
export type Validator<T extends HTMLElement = HTMLElement> = { /** * - The attributes to listen for that may affect validations. When these attributes change, we should re-run validations. Right now, this does nothing, but will be useful for "vanilla" components. */ observedAttributes?: string[] | undefined; /** * - The message to display. */ message?: string | ((...args: any[]) => string) | undefined; checkValidity: (element: T & { value?: unknown; }) => { message: string; isValid: boolean; invalidKeys: Array<Exclude<keyof ValidityState, "valid">>; }; }; export type FormValue = string | FormData | File | null;