-
Notifications
You must be signed in to change notification settings - Fork 0
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: Add body validation #49
base: main
Are you sure you want to change the base?
Conversation
d32a337
to
2d92009
Compare
src/utils/validator.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer this directory to be named data-schemas
or something similar. Opinions?
src/validator/auth.ts
Outdated
import { errors } from 'config/errors'; | ||
import { formatZodError } from 'utils/validator'; | ||
|
||
const userSchema = z.object({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const userSchema = z.object({ | |
const userCreationSchema = z.object({ |
src/validator/auth.ts
Outdated
const userSchema = z.object({ | ||
email: z.string().email({ message: 'Invalid email' }), | ||
name: z.string(), | ||
password: z.string().min(1, { message: "Can't be an empty password" }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should enforce a password with length 10 at least IMO. This should be a configuration I think. Not an environment variable, but it should be centrally defined
src/validator/auth.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also export the inferred types for each schema?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would we export the inferred types for, it shouldn't be necessary to use them outside of this file right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. I don't think it hurts to export them, they might be needed in a serializer or something.
120aea4
to
b4af7d7
Compare
src/data-schemas/auth.ts
Outdated
import { errors } from 'config/errors'; | ||
import { formatZodError } from 'utils/validator'; | ||
|
||
const passwordLength = 10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const passwordLength = 10; | |
const MINIMUM_PASSWORD_LENGTH = 10; |
b4af7d7
to
f139500
Compare
NOTION Ticket
Type of change
Description of the change
Description here
Add body validation for login and register endpoints