aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/Form.ts
blob: 2b25eb193055fdf376f587bfb603ca976c50201e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import Form from 'mobx-react-form';
import vjf from 'mobx-react-form/lib/validators/VJF';
import { FormFields } from '../@types/mobx-form.types';

export default class DefaultForm extends Form {
  // eslint-disable-next-line @typescript-eslint/no-useless-constructor
  constructor(fields: FormFields) {
    super(fields);
  }

  bindings() {
    return {
      default: {
        id: 'id',
        name: 'name',
        type: 'type',
        value: 'value',
        label: 'label',
        placeholder: 'placeholder',
        disabled: 'disabled',
        onChange: 'onChange',
        onFocus: 'onFocus',
        onBlur: 'onBlur',
        error: 'error',
      },
    };
  }

  options() {
    return {
      validateOnInit: false, // default: true
      // validateOnBlur: true, // default: true
      // validateOnChange: true // default: false
      // // validationDebounceWait: {
      // //   trailing: true,
      // // },
    };
  }

  plugins() {
    return {
      vjf: vjf(),
    };
  }
}