validation.ts 552 B

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