fix(validation): re-key cross-field rules onto a named field so forms show inline messages #262
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/pms-364-cross-field-validation-field-key"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
validator-crate keys every #[validate(schema(...))] (cross-field) error under its special
__all__bucket. The client cannot bind__all__to a form field, so a cross-field failure such as a contract's end_date < start_date degraded to the generic "Validation failed: one or more fields are invalid" banner with no indication of which field or rule was at fault.Add
utils::validation::cross_field_error(code, field, message)which records the target form field as afieldparam on the ValidationError, and teachFrom<ValidationErrors> for AppErrorto re-key any__all__error carrying that param onto the named field. The form then renders the message inline exactly like a single-field error. Ordinary single-field errors carry no such param and keep their own key, so the phone-validator pattern is unchanged.Apply the helper to all three existing cross-field rules surfaced by the audit: contract date range (-> end_date), invoice date range (-> due_date), and SLA target range (-> first_response_hours).
#PMS-364