-
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:
set()
will apply input
function also to initial
and `defau…
…lt` props `set()` will apply `input` function also to `initial` and `default` props. fix: #519
- Loading branch information
1 parent
72f4a8b
commit 97c276a
Showing
12 changed files
with
141 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { expect } from "chai"; | ||
import validatorjs from "validatorjs"; | ||
import { Form } from "../../../../src"; | ||
import FormInterface from "../../../../src/models/FormInterface"; | ||
import { ValidationPlugins } from "../../../../src/models/ValidatorInterface"; | ||
import vjf from "../../../../src/validators/VJF"; | ||
import dvr from "../../../../src/validators/DVR"; | ||
|
||
const plugins: ValidationPlugins = { | ||
vjf: vjf(), | ||
dvr: dvr(validatorjs) | ||
}; | ||
|
||
const weekValidator = ({ field, form }) => { | ||
// form.invalidate(); // <--- need to work without calling invalidate() | ||
return [false, "Error ..."]; | ||
}; | ||
|
||
const fields = [ | ||
{ | ||
name: "week", | ||
label: "week", | ||
validators: [weekValidator], | ||
fields: [ | ||
{ | ||
name: "MONDAY", | ||
label: "MONDAY", | ||
disabled: true, | ||
fields: [ | ||
{ | ||
name: "start", | ||
label: "start", | ||
// validators: [timeValidator] | ||
}, | ||
{ | ||
name: "end", | ||
label: "end", | ||
// validators: [timeValidator] | ||
} | ||
], | ||
}, | ||
{ | ||
name: "TUESDAY", | ||
label: "TUESDAY", | ||
disabled: true, | ||
fields: [ | ||
{ | ||
name: "start", | ||
label: "start" | ||
}, | ||
{ | ||
name: "end", | ||
label: "end" | ||
} | ||
], | ||
} | ||
// ...other days | ||
] | ||
} | ||
]; | ||
|
||
const hooks = { | ||
onInit(form) { | ||
form.submit(); | ||
}, | ||
}; | ||
|
||
export default new Form({ fields }, { | ||
plugins, | ||
hooks, | ||
name: '$519', | ||
options: { | ||
validateOnInit: true, | ||
showErrorsOnInit: true, | ||
retrieveOnlyEnabledFieldsValues: true, | ||
validateDisabledFields: false | ||
}}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters