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

Open
cleverbeagle opened this Issue Oct 23, 2018 · 7 comments

Comments

Projects
None yet
3 participants
@cleverbeagle
Copy link
Owner

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

This comment has been minimized.

Copy link
Owner

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

This comment has been minimized.

Copy link
Owner

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Owner

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

This comment has been minimized.

Copy link
Owner

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Owner

cleverbeagle commented Nov 13, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment