jurassix / react-validation-mixin

Simple validation mixin (HoC) for React.
MIT License
283 stars 38 forks source link

error messages doesn't clear when validating array of items #38

Closed lawuc closed 8 years ago

lawuc commented 8 years ago

I want to do validation array of payment dates. Currently, I have the following:

validatorTypes: {
  payments: Joi.array().items(Joi.date().min(effectiveDate).max(expirationDate).options({ 
    language: { date: { 
      min: 'should be in this date range Effective Date and Expiration Date',
      max: 'should be in this date range Effective Date and Expiration Date' }, label: 'Payment Date' } }))
}

when there are errors, this.getValidationMessages returns:

{
  payments: []
  payments.0: [""Payment Date" should be in this date range Effective Date and Expiration Date"]
  payments.1: [""Payment Date" should be in this date range Effective Date and Expiration Date"]
}

The validation works nicely, except the error messages doesn't clear when I inputed the correct payment date after validation failed.

How to automatically clear error messages after correct values are inputed? I'm still using 4.2.0.

Thanks.

boldt commented 8 years ago

I can comfirm that. I have the same issue on version 5.0.10.

boldt commented 8 years ago

It is the same issue with nested objects:

var schema = {
  a : Joi.string();
  local : Joi.object().keys({
    b: Joi.string(),
    c: Joi.string();
  });
}

The nested error messages will never be cleaned!

jurassix commented 8 years ago

This has been fixed with 5.2.0: https://github.com/jurassix/react-validation-mixin/releases/tag/v5.2.0

jurassix commented 8 years ago

Ensure you upgrade joi-validation-strategy to v0.2.1

boldt commented 8 years ago

Arrays and nested objects are working. Thank you!

lawuc commented 8 years ago

Awesome. Thank you!