Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(frontend): reusable validation schema #94

Merged
merged 1 commit into from
Jan 21, 2025

Conversation

sebastien-comeau
Copy link
Contributor

@sebastien-comeau sebastien-comeau commented Jan 15, 2025

This commit introduces a robust string validation schema, stringSchema, along with new validation schemas for first name, last name, and email address. These schemas leverage Zod for type safety and offer customizable options including:

  • String Length Validation: Enforce minimum and maximum string lengths.
  • Format Validation: Predefined formats (alpha-only, alphanumeric, digit-only, non-digit) and custom regular expression support.
  • Trimming: Automatic trimming of leading/trailing whitespace (configurable).
  • Customizable Error Messages: Tailor error messages for each validation rule.
  • 100% Test Coverage: Comprehensive unit tests ensure the reliability and correctness of the validation logic, covering all features and edge cases.

The new schemas (firstNameSchema, lastNameSchema, and emailAddressSchema) build upon the flexible stringSchema to provide specialized validation for common use cases. This improves data integrity and provides a consistent user experience.

@sebastien-comeau sebastien-comeau enabled auto-merge (squash) January 15, 2025 19:36
@sebastien-comeau sebastien-comeau changed the title Seb/reusable validation schema feat(frontend): reusable validation schema Jan 16, 2025
@sebastien-comeau sebastien-comeau enabled auto-merge (squash) January 16, 2025 13:39
@sebastien-comeau sebastien-comeau enabled auto-merge (squash) January 16, 2025 13:39
@sebastien-comeau sebastien-comeau force-pushed the seb/reusable-validation-schema branch 3 times, most recently from 3526b39 to 89437b7 Compare January 17, 2025 20:25
@sebastien-comeau sebastien-comeau merged commit a38cb23 into main Jan 21, 2025
7 checks passed
@sebastien-comeau sebastien-comeau deleted the seb/reusable-validation-schema branch January 21, 2025 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants