Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Skip { after: :other_attribute } validation if other_attribute is nil #87

Open
slucaskim opened this issue Feb 2, 2021 · 1 comment

Comments

@slucaskim
Copy link

🦄 Feature Request

Is your feature request related to a problem?

When I'm using the after syntax using an attribute:

validates :expiration_date, date: { after: :packaging_date }

but then packaging_date is a nilable attribute, the validation fails when packaging_date is blank.

Describe the solution you'd like

The more sensible behaviour to me is if the after validation is only applied in case where packaging_date is present. If packaging_date is blank, the date validation should just check the date format of expiration_date.
If this makes sense with the authors and the users, I'm totally willing to put in a PR!

@Ceda
Copy link

Ceda commented Feb 2, 2021

next if option_value.blank? to > https://github.com/codegram/date_validator/blob/master/lib/active_model/validations/date_validator.rb#L84

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

No branches or pull requests

2 participants