yup-validation-schemas.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import * as Yup from 'yup'
  2. const validations = {
  3. loginValidations: Yup.object().shape({
  4. username: Yup
  5. .string()
  6. .required("Please provide a username"),
  7. password: Yup
  8. .string()
  9. .required("Please provide a password")
  10. }),
  11. registerCredsValidation: Yup.object().shape({
  12. username: Yup
  13. .string()
  14. .required("Please provide a username")
  15. .min(8, 'Must be between 8 and 25 characters.')
  16. .max(20, 'Must be 20 characters or less'),
  17. email: Yup
  18. .string()
  19. .required("Please provide an email")
  20. .min(8, 'Must be between 8 and 25 characters.')
  21. .max(25, 'Must be between 8 and 25 characters.'),
  22. password: Yup
  23. .string()
  24. .required("Please provide a password")
  25. .min(8, 'Must be between 8 and 25 characters.')
  26. .min(22, 'Must be between 8 and 25 characters.'),
  27. confirmPassword: Yup
  28. .string()
  29. .oneOf([Yup.ref('password'), null], "Your passwords don't match."),
  30. }),
  31. registerMeasurementsValidation: Yup.object().shape({
  32. height: Yup
  33. .number("Please enter a valid number."),
  34. weight: Yup
  35. .number("Please enter a valid number.")
  36. }),
  37. }
  38. export default validations;