You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I'm using reform 2.5.0 with dry-validations 1.6 into rails 6.0.3 and seeing issue. I'm trying to validate a nested collection of forms from the parent form and output errors for each collection item, but form.errors.messages method returns empty hash.
Steps to reproduce
classWorkForm < Reform::Formproperty:idproperty:claim_idproperty:group_idcollection:workflows,form: WorkflowForm,populate_if_empty: Workflowvalidationdooption:formconfig.messages.backend=:i18nparamsdorequired(:group_id).filled(:int?)optional(:workflows)endrule(:group_id)dokey.failure(:already_exist)ifWork.where.not(id: form.model.id).where(group_id: value,claim_id: form.claim_id).exists?endrule(:workflows).eachdo |index:|
nextifvalue[:id]# For reproduce I removed any conditions and just raised error to fail validationkey([:workflows,:sender_id,index]).failure('invalid sender_id')endendendclassWorkflowForm < Reform::Formproperty:idproperty:work_idproperty:sender_idproperty:messageend# Now call the formirb(main):366:0> params={"group_id": 2,"workflows": [{"sender_id": 4,"message": "workflow message"}]}irb(main):366:0> form=WorkForm.new(Work.find(4))irb(main):366:0> form.validate(params)# falseirb(main):366:0> form.errors.messages# {}
If I transfer the validation to the WorkflowForm and refuse to iterate the array, there is no such problem, the error is successfully displayed. But I cannot transfer validation to a nested form as I need to compare the data from WorkForm with data from WorkflowForm form.
Complete Description of Issue
Hi! I'm using reform 2.5.0 with dry-validations 1.6 into rails 6.0.3 and seeing issue. I'm trying to validate a nested collection of forms from the parent form and output errors for each collection item, but
form.errors.messages
method returns empty hash.Steps to reproduce
Expected behavior
I did this validation according to dry-rb documentation:
https://dry-rb.org/gems/dry-validation/1.6/rules/#defining-a-rule-for-each-element-of-an-array
I expect to see something like this:
Actual behavior
But now I see an empty hash
Although if you look at the error object, you can see that the validation worked successfully and detected an error into collection:
If I transfer the validation to the WorkflowForm and refuse to iterate the array, there is no such problem, the error is successfully displayed. But I cannot transfer validation to a nested form as I need to compare the data from
WorkForm
with data fromWorkflowForm
form.System configuration
Reform version: 2.5.0
Rails version: 6.0.3
dry-validation version: 1.6.0
The text was updated successfully, but these errors were encountered: