-
Notifications
You must be signed in to change notification settings - Fork 374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async Validation with Ajv #1386
base: master
Are you sure you want to change the base?
Conversation
Introduces a way to init JSON Forms with an async validation execution. This is necessary to support async-marked schemas for which the user can register async validation functions in Ajv. * Introduce separate init actions with and without validation * Offer a thunk which executes the init action without validation and sets the errors afterwards once Ajv finished validation
* Init all examples with async validation * Configure person example to be async
Thank you, Stefan! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether it is the best solution to add thunk to all examples
I'm against extending the person schema instead of creating a dedicated example for async validation.
|
||
return error; | ||
}); | ||
export const sanitizeErrors = (validator: ValidateFunction, data: any) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to have a return type
} | ||
}; | ||
|
||
export const asyncSanitizeErrors = (validator: ValidateFunction, data: any) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to have a return type
8bd14c2
to
e9946ef
Compare
This (draft) PR introduces the concept of async validation with Ajv for #1347.
This concept is introduced next to (instead of replacing) synchronous validation. To implement the functionality we use redux-thunk to allow for chained async actions, however redux-thunk is only necessary when the user wants to use async-marked schemas.
This (draft) PR contains the thunk for JSON Forms initialization with an async Ajv validation run, see
Actions.initAsyncValidation
. The (currently) last commit enables the async behavior for all examples, however only the person example is actually marked async (the remaining examples use a fallback).Open tasks:
SET_AJV
andUPDATE_DATA
.