react-form-with-constraints
Version:
Simple form validation for React
38 lines (37 loc) • 1.23 kB
TypeScript
export interface TextInput {
props: {
name: string;
value?: string;
};
}
export declare class IValidityState implements ValidityState {
readonly badInput: boolean;
readonly customError: boolean;
readonly patternMismatch: boolean;
readonly rangeOverflow: boolean;
readonly rangeUnderflow: boolean;
readonly stepMismatch: boolean;
readonly tooLong: boolean;
readonly tooShort: boolean;
readonly typeMismatch: boolean;
readonly valid: boolean;
readonly valueMissing: boolean;
constructor(validity: ValidityState);
}
export declare type HTMLInput = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
export interface IHTMLInput {
readonly name: string;
readonly type: string;
readonly value: string;
readonly validity: IValidityState;
readonly validationMessage: string;
}
export declare function isHTMLInput(input: IHTMLInput | TextInput): input is IHTMLInput;
export declare class InputElement implements IHTMLInput {
readonly name: string;
readonly type: string;
readonly value: string;
readonly validity: IValidityState;
readonly validationMessage: string;
constructor(input: IHTMLInput | TextInput);
}