@mobx-ecosystem/mobx-form
Version:
provides the ability to use forms with validation in MobX stores
34 lines (33 loc) • 1.21 kB
TypeScript
import { FormServiceValuesType, FormValues, IField, IFormable, ValidationType } from './types';
export declare class CombinedFormFieldService<T extends IFormable<FormServiceValuesType> = IFormable<FormServiceValuesType>> implements IField {
private _touched;
private _disabled;
private _error?;
private _initValue;
private _value;
_validate?: () => Promise<unknown>;
constructor(initValue?: T[]);
get initValue(): T[];
set initValue(_initValue: T[]);
get value(): T[];
set value(array: T[]);
get disabled(): boolean;
set disabled(disabled: boolean);
get error(): string | undefined;
set error(error: string | undefined);
get isValid(): boolean;
get isTouched(): boolean;
get isInit(): boolean;
get hasItems(): boolean;
private setTouched;
add: (value: T) => void;
removeByIndex: (index: number) => void;
reset: () => void;
setAsInit: () => void;
getValues: () => FormValues<T["formService"]["fields"]>[];
touch: () => void;
validateFields: (type?: ValidationType) => Promise<void[]>;
validate: (type?: ValidationType) => Promise<[unknown, void[]]>;
disable: () => void;
enable: () => void;
}