Giter VIP home page Giter VIP logo

Comments (3)

dvdzkwsk avatar dvdzkwsk commented on April 28, 2024

Thanks for checking it out, I appreciate your thoughts. You're totally right, however I intentionally ignored the rabbit hole of more intricate (read: correct) form validation as there too many things to consider and this was really meant as a proof of concept.

It would be fairly trivial to implement a isDirty flag on each field, which I think would be the ideal route since initialModel[field] === model[field] is not necessarily correct (initialize w/ empty password, they type something in, delete it; fields are now the same, but invalid).

I'd be open to considering improvements in this regard, though the purpose of this library is almost exclusively to supply the model + getter/setters for it from a higher order component. The rest of the functionality is demo'd to show it's possible, but expected to be more thoroughly implemented in userland.

from react-reformed.

arendjr avatar arendjr commented on April 28, 2024

The way I've implemented this for myself (using reformed as base) is to create a validationFeedback middleware. This creates a higher-order component that provides two props: getErrorClass and showValidationFeedback. getErrorClass is what I use to display an error indication on my form fields and returns a CSS class name to be fed into classnames. The trick is that it never returns a CSS class until showValidationFeedback has been called at least once. I call showValidationFeedback when the user clicks the submit button (which is always enabled for these forms) and I also use this function to display textual error messages in a ticker and to move focus to the first field with an error.

Of course this approach already makes some assumptions about what your actual form implementation looks like, so your mileage may vary, but hopefully this gives you some ideas.

from react-reformed.

dvdzkwsk avatar dvdzkwsk commented on April 28, 2024

Thanks for the suggestion @arendjr, that sounds like a pretty sane approach.

I'm going to close this issue just to tidy up the project some, since it's more of a discussion than anything. I'll direct people to your suggestion if this comes up again :).

from react-reformed.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.