-
Notifications
You must be signed in to change notification settings - Fork 433
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
Formsy 1.0.0 release info preview #83
Comments
I've been experimenting with different form libraries for react and I think formsy is very good. Thanks for putting it together. However, I think it is still lacking on the validation front. Validations are common and often the same validation is used over and over again. Take I think Rails does this pretty well, where you'd say, validates_email :foo which will check whether validates_email :foo, :message => "really needs to be an email address" The main point here is a field has a list of validators. All that validator needs to do is take a value (or perhaps all the values from the form) and produce an error string or null if there is no error (i.e. it is valid). Translating this to type of approach to formsy, maybe you'd end up with something like,
This would first check whether I could change the default messages with maybe,
Or I could provide a custom message and / or custom validators,
Thanks for listening. Let me know what you think. Edit: minor naming change. |
One more thought ... I was looking at I18N and http://formatjs.io/react/. It would be good to support localization for error messages. Any idea on how to support something like http://formatjs.io/react/? |
Awesome, I dig the flexible But I think React 0.14 will take some time to hit the stove and I keep getting the mutation warnings in my forms. Maybe you could make a pre-1.0 using the parent-child context? cheers |
Hi, maybe I just didn't get it, is it that Formsy v1.0.0 will not require the use of mixins anymore? |
Hi @janmyler , Sorry for late response. Formsy will still require mixins, but the relationship between the form and the form elements will technically use context. It is more performant than the current solution and the Formsy.Form element and its child form elements can actually live in different "owners". Which basically means they can live inside different "render" methods and still have a relationship. |
@pkmiec 👍 very important to keep i18n in mind, and React Intl is the de-facto solution right now. |
@pkmiec and @firstdoit , yeah, I totally agree. I have no experience with React Intl (You referring to Yahoo?) or formatjs, but I am very open to suggestions and examples of how to handle this! |
i18n is a great idea. However, to better integrate into existing projects, no module should be imposed. The ideal would be to go through an adapter, like this: Formsy.translate(function(errorMessage) {
return anyTranslator(errorMessage);
}); Or via a config container: Formsy.config.translate(function(errorMessage) {
return anyTranslator(errorMessage);
}); |
React 0.14 is now in Beta and I am working on the next release. When 0.14 is released and the new version has been tested, we go for 1.0 release :-) When it comes to translation I do not see why formsy needs a wrapper for this. As you probably have other translations in your project already, so: <MyInput validations="isEmail" validationErrors={{isEmail: translate('invalidEmail') }}/> It would work just like translating any other text in your components? Closing this issue as things are moving along. |
Indeed, it makes sense |
Hi there,
We are moving towards a 1.0.0 release. The API has become very flexible and powerful and though I am sure there will still be lots of more input the library and its API has been a proven valuable tool. Thanks a lot for all contributions!
First of all Formsy v1.0.0 will be released when React 0.14.0 is released. The reason for that is a feature change internally in React which allows Formsy to pass hooks down to the form element children with a concept called
parent-children-context
. This issue confirms the feature for React 0.14.0. The Formsy implementation is ready, we just have to wait.There will also be a few changes:
validations
prop can now pass an object with validations instead of a string. This allows for more complex validation, like passing regexps etc.required
will also be able to pass validation rules. By default it checks for empty string, but if your element is a checkbox you might want to check if the value is false to indicate that it is required.validationErrors
. This is the same asvalidationError
, but it allows you to pass an object indicating what rule should give what error.The text was updated successfully, but these errors were encountered: