-
Notifications
You must be signed in to change notification settings - Fork 49
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
validates: { ... } duplicate error messages #59
Comments
I have the same issue using reform 2.3.0rc1 and reform-rails 0.2.0rc2 on Rails 5.2.1. |
I just tested it with the same reform and reform-rails version for a Rails 4.2.10 app and there the problem does not occur. |
I know it's an old issue but it seems like I'm still seeing this error when inheriting a property from a contract. The following example leads to the problem: class Parent < Reform::Form
property :title, validates: { presence: true }
end
class Child < Parent
end
contract = Child.new(OpenStruct.new)
contract.validate({})
contract.errors.details
# => { title: [{ error: :blank }, { error: :blank }] } I looked into it and seems to be related to the heritage system of disposable. We inherit property definitions AND validations from the parent form. This leads to duplicate validation creation in the child contract because it will receive the validation from the parent property definition and the parent validation definition. I tried fixing this by deleting the Could you help me/us with this? @apotonick |
In my form I have such property and its validations declaration:
Both when declaring property with
property
orproperties
validation errors are duplicate. However, when I separate validations from property declaration:Duplication are no longer there. So it seems that
validates: { ... }
causes error duplication.I know this issue was reported in trailblazer/trailblazer #109 and was closed as it seemed that updating from reform 2.1 to 2.2 solved it. In my case i use reform-rails 0.1.7 and reform 2.2 and problem is still there or was reintroduced.
The text was updated successfully, but these errors were encountered: