validation.js 541 B

1234567891011121314151617181920
  1. export default {
  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. name: /^[\p{L} .'-]+$/u,
  8. password: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~])[A-Za-z\d!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]/,
  9. custom: regex => {
  10. return new RegExp(`^[${regex}]+$`);
  11. }
  12. },
  13. isLength: (string, min, max) => {
  14. return !(
  15. typeof string !== "string" ||
  16. string.length < min ||
  17. string.length > max
  18. );
  19. }
  20. };