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: Add body validation #49

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

gabrielmachin
Copy link
Collaborator

NOTION Ticket

Type of change

  • Fix
  • Story
  • Chore

Description of the change

Description here

Add body validation for login and register endpoints

Copy link
Collaborator

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?

import { errors } from 'config/errors';
import { formatZodError } from 'utils/validator';

const userSchema = z.object({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const userSchema = z.object({
const userCreationSchema = z.object({

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" }),
Copy link
Collaborator

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

Copy link
Collaborator

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?

Copy link
Collaborator Author

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?

Copy link
Collaborator

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.

@gabrielmachin gabrielmachin force-pushed the feat/Add-body-validation branch 3 times, most recently from 120aea4 to b4af7d7 Compare January 17, 2024 17:46
import { errors } from 'config/errors';
import { formatZodError } from 'utils/validator';

const passwordLength = 10;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const passwordLength = 10;
const MINIMUM_PASSWORD_LENGTH = 10;

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