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

How do I derive a schema with more validations/transformations? #488

Closed
edygar opened this issue Mar 18, 2024 · 2 comments
Closed

How do I derive a schema with more validations/transformations? #488

edygar opened this issue Mar 18, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@edygar
Copy link

edygar commented Mar 18, 2024

How do I derive a schema adding things to its pipe? I got it working with the following snippet, but it's definitely confusing:

// a file
const LoginSchema = v.object({
  email: v.string([v.minLength(1), v.email()]),
  password: v.string([v.minLength(1), v.minLength(8)]),
})

// another file
const CreateLoginSchema = v.intersect([LoginSchema, v.object({)], [
  checkEmailAvailabiliy, // validations/transformations I want to add 
  checkPasswordRules // on top of the previous schema
])
@fabian-hiller
Copy link
Owner

We plan to improve this part of the library: #463

@fabian-hiller fabian-hiller self-assigned this Mar 19, 2024
@fabian-hiller fabian-hiller added the enhancement New feature or request label Mar 19, 2024
@fabian-hiller
Copy link
Owner

This should now be possible using our new pipe function. 🧩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants