validation.js 468 B

12345678910111213141516171819
  1. module.exports = {
  2. regex: {
  3. azAZ09_: /^[A-Za-z0-9_]+$/,
  4. az09_: /^[a-z0-9_]+$/,
  5. emailSimple: /^[\x00-\x7F]+@[a-z0-9]+\.[a-z0-9]+(\.[a-z0-9]+)?$/,
  6. ascii: /^[\x00-\x7F]+$/,
  7. password: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]/,
  8. custom: regex => {
  9. return new RegExp(`^[${regex}]+$`);
  10. }
  11. },
  12. isLength: (string, min, max) => {
  13. return !(
  14. typeof string !== "string" ||
  15. string.length < min ||
  16. string.length > max
  17. );
  18. }
  19. };