Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

updated docs #16

Merged
merged 1 commit into from
Mar 8, 2019
Merged

updated docs #16

merged 1 commit into from
Mar 8, 2019

Conversation

aizerin
Copy link
Contributor

@aizerin aizerin commented Mar 7, 2019

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.

@tommmyy
Copy link
Contributor

tommmyy commented Mar 7, 2019

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 createOptionalValidation. I think that should be used in intl package instead of createValidation. The obligation of a field should be solved by isRequired validation.

@@ -2,10 +2,12 @@

[![build status](https://img.shields.io/travis/lundegaard/validarium/master.svg?style=flat-square)](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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, it is not agnostic yet... but it is definitely our goal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will create issue

<br />
<br />

[`Try It`](https://runkit.com/aizerin/validarium)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

* [.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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that there shoud be .createOptionalValidation


**Example**
```js
validateMany({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please adjust the formatting of all examples (indentation in particular)?

},
])

// [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be createOptionalValidation

@tommmyy tommmyy merged commit 8ed1cca into lundegaard:master Mar 8, 2019
@tommmyy
Copy link
Contributor

tommmyy commented Mar 8, 2019

@aizerin Thank you for great work!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants