updated docs#16
Conversation
|
I am all in for agnostic principle. The hard-coding of https://github.com/lundegaard/validarium/blob/master/packages/core/src/createMainValidate.js#L74 I consider as a bug that must be solved. Have you thought about the way how to do that? Referring to |
| [](https://travis-ci.org/lundegaard/validarium) | ||
|
|
||
| An agnostic validation library for JavaScript applications. | ||
| An validation library for JavaScript applications. Ready to be used with react-intl. |
There was a problem hiding this comment.
Ok, it is not agnostic yet... but it is definitely our goal.
| <br /> | ||
| <br /> | ||
|
|
||
| [`Try It`](https://runkit.com/aizerin/validarium) |
| * [.validateMany](#module_core.validateMany) | ||
| * [.createMainValidate](#module_core.createMainValidate) ⇒ <code>Object</code> | ||
| * [.createValidation(fn, react, params)](#module_core.createValidation) ⇒ <code>Object</code> \| <code>null</code> | ||
| * [.createValidation(fn, react, params)](#module_core.createValidation) ⇒ <code>Object</code> \| <code>null</code> |
There was a problem hiding this comment.
I think that there shoud be .createOptionalValidation
| <a name="module_core.createValidation"></a> | ||
|
|
||
| ### core.createValidation(fn, react, params) ⇒ <code>Object</code> \| <code>null</code> | ||
| Creates optional validation function with predicate and message |
There was a problem hiding this comment.
I think that there shoud be .createOptionalValidation
|
|
||
| **Example** | ||
| ```js | ||
| validateMany({ |
There was a problem hiding this comment.
Can you please adjust the formatting of all examples (indentation in particular)?
| }, | ||
| ]) | ||
|
|
||
| // [ |
There was a problem hiding this comment.
Can you please add a line of a comment text above the output of an example that will make more obvious that this is an output of a code above? E.g.:
// Output:
// [{
// ......
instead of ust
// [{
// ......
| * @param {Object} params for intl message (eg. { min: 1, max: 2 }) | ||
| * @return {Object|null} Message object when fails { message, messageValues } or null if pass | ||
| * | ||
| * @alias module:core.createValidation |
There was a problem hiding this comment.
I think it should be createOptionalValidation
|
@aizerin Thank you for great work! |
I’ve updated docs.
But I have a few problems with this library.
The library is not agnostic since it requires react-intl to be present in props in the core of the library.
Function createMainValidate requires props and react-intl. Beside that createMainValidate is not actually self-explanatory name when it also translating the validation messages.
Whole intl package has only mandatory validations. There is no way to have optional validations since every validation is created using createValidation. Should I duplicate every validation using createOptionalValidation if I want to optional validations? This implies that isRequired is there only for a fancy error message.
This library is maybe too simple to even for simple form validation. There is no solution for conditional validations, async validations, nested object and objects in arrays.