Code Monkey home page Code Monkey logo

Comments (7)

richardaday avatar richardaday commented on May 19, 2024 1

Doesn't that go against what we're seeing with HTML5 forms? Inputs are declaring their own validation rules through parameters (required, maxlength, etc).

The idea of being able to use an "EmailInput" and adding a required property to it and having it "just work" is alluring. Am I the only one? Would this be a benefit to you or your application?

from redux-form.

erikras avatar erikras commented on May 19, 2024

I would argue/suggest that the validation is "business" (not presentation) logic, and perhaps should not be done in the individual input component. I prefer input components that take a name, label, value and error message, and let the validator for the whole form perform the validation.

You can, of course, still use redux-form without the validation part, and do the validation separately, either on the fly, with onBlur or onChange, or later onSubmit. By doing it in the component, no matter what, you're going to have to cycle through them to check isValid before submitting, whether you use redux-form for the validation or not.

Don't know if that helps at all...?

from redux-form.

olivierrr avatar olivierrr commented on May 19, 2024

I agree with @erikras

from redux-form.

erikras avatar erikras commented on May 19, 2024

Yes, it does. And you should still use things like type="email" in your inputs, primarily to inform mobile devices with software keyboards, however React bucks a lot of industry trends, such as controller/view separation and even stylesheets.

React trends, like stateless function components, are pushing in the opposite direction, taking away as much logic and state from the leaves of the "DOM" tree as possible.

I'm not denying that the old way of having a toolbox of smart components to handle your validation is/was not useful; I have built and used them myself, but we're at a bit of a philosophical impasse here. From my vantage point, I think it's the wise move to choose functional over OO (to cite another example) and dumb stateless components over smart stateful components when encountering such forks in the design road.

I'm not even sure what redux-form could do to make the job of a component-based validation system easier...provide some sort of registry for sub-components to check in with? What would that even look like?

this.context.registerValidation('name', value => value.length > 25 ? 'Too long' : true);

??

from redux-form.

snowcxt avatar snowcxt commented on May 19, 2024

We need this feature too. If you can provide #165 + get values function, that will be great.

from redux-form.

ooflorent avatar ooflorent commented on May 19, 2024

HTML5 validation is not currently supported (#254).

However, if your component accepts onBlur, onFocus and onChange properties, it can mimic a native input and may be reusable.

from redux-form.

lock avatar lock commented on May 19, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from redux-form.

Related Issues (20)

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.