foxhound87 / mobx-react-form

Reactive MobX Form State Management
https://foxhound87.github.io/mobx-react-form
MIT License
1.09k stars 129 forks source link

confirmed rule from validatorjs cannot work #45

Closed djhi closed 7 years ago

djhi commented 7 years ago

Hi,

The confirmed rule from validatorjs cannot work currently as the validateFieldSync method only passes the field to validate instead of the fields array.

I'll try to submit a PR about this asap

foxhound87 commented 7 years ago

I don't like so much the implementation of the confirmed rule as it enforce to use underscore for the field name that ends with _confirmation.

We should instead reimplement it to work like shouldBeEqualTo(fieldName) validation function: https://github.com/foxhound87/mobx-react-form/blob/master/docs/CustomValidationFunctions.md#define-custom-functions (but without the needs of the additional prop related: ['theFieldName']).

In fact, now, I think that the confirmed rule will need the related prop too, this because I am creating a new instance for each field. Otherwise we must provide the 2 fields (data and rules) and handle the error message for those inputs in a different way.

Thank you for your involvement and help!

djhi commented 7 years ago

I agree as I don't like it much too but if you provide the option to use validatorjs, shouldn't we expect it to work as it has been designed to ?

foxhound87 commented 7 years ago

Yes it should, but it's not high priority right now. Are you working on it anyway?