input-props
Version:
A React component that provides a two-way data-binding feel to your forms controlled by a mobx state.
26 lines (25 loc) • 908 B
TypeScript
declare type FieldType<T> = keyof T;
export declare class FormErrorHandler<T extends any> {
errors: {
field: FieldType<T>;
error: string;
}[];
/** whether there's any error in any field */
get hasError(): boolean;
/** use this method to add an error to field.
* field must be the the string property name of the field in the model that you are setting the error
*/
error(field: FieldType<T>, error: string): void;
/** checks whether a field has any error */
fieldHasError(field: FieldType<T>): boolean;
/** gets the error for any specific field */
getFieldError(field: FieldType<T>): {
error: boolean;
helperText: string;
};
/** reset error for specific field */
resetFieldError(field: FieldType<T>): void;
/** reset all errors */
reset(): void;
}
export default FormErrorHandler;