feat(contacts): validate phone/timezone/country/postal (fix contact phone 500) [PMS-325] #247
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/PMS-325-contact-field-validation"
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?
What
Backend field validation for contacts, companies, and sites (PMS-325). Phone, time zone, country, and postal code were previously unvalidated, so bad input was either stored as-is or failed downstream and surfaced as an HTTP 500 (the reported "contact phone" failure). Each is now a clear, per-field 422 so the client can show the user exactly what to fix.
Changes (crate
mokosh-types)+1 (415) 555-1234is stored as+14155551234, then a validator enforces E.164 (optional+, 2-15 digits, first 1-9). Non-numeric input (e.g.not-a-phone) is rejected rather than silently emptied.chrono-tz.America/New York(space) is rejected;America/New_Yorkis accepted.USA/United Statesare rejected.Address(now nest-validated on sites too).chrono-tztomokosh-types.Tests
tests/contacts.rs): invalid phone -> 422 (not 500), spaced time zone -> 422, non-ISO country -> 422, over-long postal -> 422, and a formatted phone round-tripping as normalized E.164. Existing contact/company/site tests updated for the new normalized phone form and ISO country.Verification
cargo test -p mokosh-typesand the fulltests/contacts.rssuite (10/10) green against Postgres.cargo clippy --all-targets -- -D warningsandcargo fmt --all --checkclean.Client-side inline mirror is MAPPS-177 (linked).
#PMS-325