-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
Hi @Gregwar,
I've a case with 2 constraints but only 1 is returned in check:
$form2->addConstraint('quantidade_assentos', function($form) {
if (empty($form->getValue('quantidade_assentos'))) {
return 'Quantidade de assentos é obrigatória!';
}
return null;
});
$form2->addConstraint('quantidade_assentos', function($form) {
if (!is_numeric($form->getValue('quantidade_assentos'))) {
return 'Quantidade de assentos deve ser número inteiro!';
}
return null;
});
Dump of getFields():
"quantidade_assentos" => NumberField {#613 ▼
#type: "number"
#min: "1"
#max: null
#step: "1"
#name: "quantidade_assentos"
#index: null
#hook: null
#attributes: array:3 [▶]
#value: ""
#required: true
#regex: null
#minlength: null
#maxlength: null
#prettyname: null
#readonly: false
#valueChanged: true
#constraints: array:2 [▼
0 => Closure {#606 ▶}
1 => Closure {#605 ▶}
]
#mapping: null
#language: English {#625 ▶}
}
Dump of errors:
array:1 [▼
0 => Error {#604 ▼
-field: NumberField {#613 ▶}
-message: array:2 [▼
0 => "value_required"
1 => "quantidade_assentos"
]
#language: English {#625 ▶}
}
]
In my view, there should be 2 errors because a empty value "" is catched in both constraints.
Any error in my logic?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels