CristiRazvi / enum_attributes_validation

Enum Attributes Validation provides validation functionality for enum attributes in models.
MIT License
32 stars 7 forks source link

Small fixes for setting enum attributes #15

Closed janospapp closed 1 year ago

janospapp commented 1 year ago

The PR includes two changes:

  1. When we set an invalid enum value, the error gets added to the enum_invalid_attributes hash. Then if later we set a valid value, then the value gets set, but the error has been also kept in the errors, and the validation failed referring to the first, invalid value. With this change, upon setting a valid value for an attribute, that attribute's error is cleared (if there was any).
  2. It allows to set nil values after a valid value is set for the attribute. There can be optional enum fields, which should be able to reset to nil after having a valid value. nil values can be handled with database level null constraints, and presence validations.
janospapp commented 1 year ago

@CristiRazvi please take a look when you have time.

CristiRazvi commented 1 year ago

nice updates @janospapp

janospapp commented 1 year ago

Thanks @CristiRazvi. Could you please release a new version of the gem (v 0.1.8)? There were also a few other changes since the last release. Let me know if I can help with anything related to that.