Skip to content

Commit

Permalink
make code more functional programming paradigm
Browse files Browse the repository at this point in the history
Signed-off-by: Amndeep Singh Mann <[email protected]>
  • Loading branch information
Amndeep7 committed Dec 30, 2024
1 parent ef987e1 commit 16c7b44
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions apps/backend/src/pipes/password-complexity.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,11 @@ import {
} from '@nestjs/common';

export function validatePassword(password?: string): string[] {
const errors = [];
if (typeof password !== 'string') {
errors.push('Password must be of type string');
return ['Password must be of type string'];
} else {
validators.forEach((validator) => {
if (!validator.check(password)) {
errors.push(validator.name);
}
});
return validators.filter(validator => !validator.check(password)).map(validator.name)a;
}

return errors;
}

@Injectable()
Expand Down

0 comments on commit 16c7b44

Please sign in to comment.