Skip to content

Commit

Permalink
Create input-validator.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Sep 17, 2024
1 parent d022d08 commit eb88bbb
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions utils/input-validator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// input-validator.js
const validator = require('validator');

class InputValidator {
validateString(input) {
return validator.isString(input) && validator.trim(input) !== '';
}

validateEmail(input) {
return validator.isEmail(input);
}

validatePassword(input) {
return validator.isStrongPassword(input, {
minLength: 12,
minLowercase: 1,
minUppercase: 1,
minNumbers: 1,
minSymbols: 1,
});
}
}

module.exports = InputValidator;

0 comments on commit eb88bbb

Please sign in to comment.