chore(validator): refactor types#175
Merged
Merged
Conversation
Contributor
EmanFateen
commented
May 14, 2026
| Q | A |
|---|---|
| License | GPLv3 |
| Issue | Closes #<issue_number> |
imdhemy
approved these changes
May 14, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the validator module’s type definitions by splitting the former types.ts into more focused type modules (payload, schema, constraint, constraint-validator, violation) and updates the validator/middleware/constraints to use the new type locations.
Changes:
- Introduces new dedicated type modules (
violation,payload,schema,constraint,constraint-validator) and removessrc/validator/types.ts. - Moves
createValidatorimplementation intosrc/validator/factory/create-validator.tsand updates middleware/constraints/tests to use the refactored type structure. - Updates the validator public entrypoint exports (
src/validator/index.ts) to reflect the new module layout.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/validator/violation.ts | New standalone Violation type. |
| src/validator/validator.ts | Now only defines the Validator function type using new type modules. |
| src/validator/types.ts | Removes the previous consolidated types module. |
| src/validator/schema.ts | Introduces FieldSchema/ValidationSchema types for schema DSL. |
| src/validator/payload.ts | New standalone Payload type. |
| src/validator/middleware/create-validation-middleware.ts | Updates middleware to accept ValidationSchema and new type imports. |
| src/validator/middleware/create-validation-middleware.test.ts | Updates test imports to new type modules. |
| src/validator/index.ts | Adjusts public exports to new module structure and factory entrypoint. |
| src/validator/flatten-violations.ts | Updates Violation import path. |
| src/validator/flatten-violations.test.ts | Updates Violation import path in tests. |
| src/validator/factory/create-validator.ts | New home for validator creation + schema normalization logic. |
| src/validator/factory/create-validator.test.ts | Updates test imports to new type modules and paths. |
| src/validator/constraints/string/slug.ts | Updates imports to new constraint/violation types. |
| src/validator/constraints/string/slug.test.ts | Updates test type imports to new modules. |
| src/validator/constraints/string/email.ts | Updates imports to new constraint/violation types. |
| src/validator/constraints/string/email.test.ts | Updates test type imports to new modules. |
| src/validator/constraints/other/compound.ts | Renames/retargets nested “rules” typing to FieldSchema. |
| src/validator/constraints/other/compound.test.ts | Updates test imports to new type modules. |
| src/validator/constraints/other/compound.integration.test.ts | Updates createValidator import path. |
| src/validator/constraints/basic/not-blank.ts | Updates imports to new constraint/violation types. |
| src/validator/constraints/basic/not-blank.test.ts | Updates test type imports to new modules. |
| src/validator/constraint.ts | Adds ConstraintOptions and ConstraintSchema types. |
| src/validator/constraint-validator.ts | Adds ConstraintContext/ConstraintValidator types (and nested schema typing). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.