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

Isomorphic Validation #244

Closed
cleverbeagle opened this issue Oct 23, 2018 · 8 comments
Closed

Isomorphic Validation #244

cleverbeagle opened this issue Oct 23, 2018 · 8 comments
Labels

Comments

@cleverbeagle
Copy link
Owner

@cleverbeagle cleverbeagle commented Oct 23, 2018

This has been on my mind for awhile and needs some attention. Currently, our validation is split between jQuery Validation on the client and (as of 2.0) our GraphQL schema on the server. Ideally, we can simplify this by having a single layer of validation that covers both client/server.

This is a big project so will have to come after 2.0 but want to make note of it now so it's on our radar.

@cleverbeagle
Copy link
Owner Author

@cleverbeagle cleverbeagle commented Oct 25, 2018

Note: storing validation code in another file as a pattern? We're adding the <Validation /> component in 2.0 but that's based on jQuery Validation. Validation can get kind of hefty so this might be nice.

@cleverbeagle
Copy link
Owner Author

@cleverbeagle cleverbeagle commented Oct 25, 2018

Possible API:

<Validation
  rules={{
    '[name="cssSelector"] or React Ref': [
      { rule: 'required', message: 'This field is required.' },
      { rule: 'email', message: 'This field must be an email.' },
      { rule: (input) => { return input > 0; }, message: 'This must be a number greater than 0.' },
    ]
  }}
>
{/* Form to validate */}
</Validation>
@sabativi
Copy link

@sabativi sabativi commented Oct 26, 2018

What about using https://github.com/vazco/uniforms/ ?
It can take schema definition as a starter for building and validating form.

@cleverbeagle
Copy link
Owner Author

@cleverbeagle cleverbeagle commented Oct 29, 2018

This looks neat, I'll take a look @sabativi :)

@cleverbeagle cleverbeagle added this to the 2.1.0 milestone Nov 9, 2018
@cleverbeagle
Copy link
Owner Author

@cleverbeagle cleverbeagle commented Nov 9, 2018

Flagging this as a 2.1 thing to motivate research but may end up moving it to later release based on results.

@ArchiCroc
Copy link

@ArchiCroc ArchiCroc commented Nov 12, 2018

@cleverbeagle I've used uniforms for one of my past projects and I started work on an example of what uniforms might look like in Pup. See https://github.com/ArchiCroc/pup/tree/feature/uniforms.

@cleverbeagle
Copy link
Owner Author

@cleverbeagle cleverbeagle commented Nov 13, 2018

Thanks for sharing @ArchiCroc :) I'll take a look.

@cleverbeagle cleverbeagle removed this from the 2.1.0 milestone Jul 29, 2019
@ayhid
Copy link

@ayhid ayhid commented Sep 6, 2019

I've used both https://github.com/vazco/uniforms/ and https://jaredpalmer.com/formik/ and I've to say the latter was a way more flexible when it comes to complex forms.

Now each time I start a new pup project I remove the Validation component and install formik with yup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants