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

Too much repeated code : Using a validation library like Joi or Zod can indeed help improve code readability and provide a DRY code structure #151

Open
sharmag44 opened this issue Mar 7, 2024 · 1 comment

Comments

@sharmag44
Copy link

const email = input.email?.trim();
const username = input.username?.trim();
const password = input.password?.trim();
const { image, bio, demo } = input;

if (!email) {
throw new HttpException(422, { errors: { email: ["can't be blank"] } });
}

if (!username) {
throw new HttpException(422, { errors: { username: ["can't be blank"] } });
}

if (!password) {
throw new HttpException(422, { errors: { password: ["can't be blank"] } });
}

export const updatePassword = {
  params: Joi.object().keys({
    id: Joi.string().custom(objectId),
  }),
  body: Joi.object().keys({
    password: Joi.string().required(),
    newPassword: Joi.string().required(),
  }),
}
@sharmag44 sharmag44 changed the title Too much repeated code Using a validation library like Joi or Zod can indeed help improve code readability and provide a DRY code structure Too much repeated code : Using a validation library like Joi or Zod can indeed help improve code readability and provide a DRY code structure Mar 7, 2024
@pushpitkamboj
Copy link

can i work on this issue if the project still needs the issue to be resolved?

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

No branches or pull requests

2 participants