Skip to content

fix(form): validate conflicting field options - #658

Open
oxura wants to merge 2 commits into
cot-rs:masterfrom
oxura:feat/294-validate-form-options
Open

oxura wants to merge 2 commits into
cot-rs:masterfrom
oxura:feat/294-validate-form-options

Conversation

@oxura

@oxura oxura commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Closes #294.

Form fields currently accept contradictory custom options and only complain later while cleaning a submitted value. That makes an invalid field definition look healthy until a request happens to exercise it.

This moves the invariant to field construction. Text length ranges, numeric ranges, and date/time ranges now reject min > max from FormField::with_options, while equal bounds and unconstrained fields keep working as before. The shared field macro calls a small internal validation trait, so each field family owns its option invariant without duplicating construction logic.

I also replaced the old delayed email-validation test and added construction-time coverage for every constrained field family.

Checked with:

  • cargo test -p cot --all-features form::fields (113 passed)
  • cargo clippy -p cot --all-targets --all-features -- -D warnings
  • cargo fmt --all -- --check
  • git diff --check

@github-actions github-actions Bot added the C-lib Crate: cot (main library crate) label Sep 2, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-lib Crate: cot (main library crate)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Form fields' custom options should be validated when constructing the field

1 participant