gothinkster / gothinkster/node-express-realworld-example-app
Too much repeated code : Using a validation library like Joi or Zod can indeed help improve code readability and provide a DRY code structure
- Dominant language
- TypeScript
- Stars
- 3.8k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
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"] } });
}
```Typescript
export const updatePassword = {
params: Joi.object().keys({
id: Joi.string().custom(objectId),
}),
body: Joi.object().keys({
password: Joi.string().required(),
newPassword: Joi.string().required(),
}),
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.