Improving Requester Name & Phone Validation in Order Entry

While working on improving the Order Entry form validation, I noticed that the existing validation logic for requester names and phone numbers was too basic. It only checked for required fields, but didn’t enforce:

Only alphabetical characters in names
Proper phone number formatting
Better inline error visibility

This led to inconsistent form behavior and poor user experience when incorrect data was entered.


What This PR Does

I’ve created a pull request to enhance validation with minimal and effective changes, without introducing any new libraries.

PR Link: https://github.com/DIGI-UW/OpenELIS-Global-2/pull/2990

The improvements include:

Stricter Name Validation

  • Ensures requester first and last names contain:

    • Letters only

    • Spaces

    • Hyphens and apostrophes (common in real names)

  • Rejects numbers and special characters

Simplified Phone Validation

  • Enforces a 10-digit phone number

  • Allows only digits

  • Optional field, but validated strictly when provided

Better User Feedback

  • Inline error messages show immediately after moving out of the field (onBlur)

  • Only one clear validation message per field


Why This Matters

This approach:
Improves UX by preventing invalid data from being entered
Reduces repeated logic by using optimized Yup validation
Keeps backend validation unchanged
Follows the existing code structure and design guidelines
Isn’t too restrictive — still practical for real-world names