Skip to content
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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Conversation

sdirix
Copy link
Member

@sdirix sdirix commented May 28, 2019

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:

  • Implement same behavior for the remaining core actions which perform validation: SET_AJV and UPDATE_DATA.
  • Check whether we can offer dispatching-functions which either use the normal action or the preconfigured thunk depending on whether the current schema is marked asynchronous.
  • Make sure the correct update data action / thunk is called depending on the circumstances
  • Write testcases.

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
@edgarmueller
Copy link
Contributor

Thank you, Stefan!

@edgarmueller edgarmueller removed their assignment Jun 13, 2019
Copy link
Member

@eneufeld eneufeld left a 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) => {
Copy link
Member

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) => {
Copy link
Member

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

@sdirix sdirix force-pushed the master branch 2 times, most recently from 8bd14c2 to e9946ef Compare December 15, 2023 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants