You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.2 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
5 years ago
2 years ago
5 years ago
2 years ago
2 years ago
  1. // Rules for project label.
  2. export const colorRules = (msg) => {
  3. return [(v) => !!v || msg.colorRequired]
  4. }
  5. export const labelNameRules = (msg) => {
  6. return [(v) => !!v || msg.labelRequired, (v) => (v && v.length <= 30) || msg.labelLessThan30Chars]
  7. }
  8. // Rules for project member.
  9. export const userNameRules = (msg) => {
  10. return [
  11. (v) => !!v || msg.userNameRequired,
  12. (v) => (v && v.length <= 30) || msg.userNameLessThan30Chars
  13. ]
  14. }
  15. export const roleRules = (msg) => {
  16. return [(v) => !!v || msg.roleRequired]
  17. }
  18. // Rules for Document.
  19. export const fileFormatRules = (msg) => {
  20. return [(v) => !!v || msg.fileFormatRequired]
  21. }
  22. export const uploadFileRules = (msg) => {
  23. return [
  24. (v) => !!v || msg.fileRequired,
  25. (v) => !v || v.some((file) => file.size < 100000000) || msg.fileLessThan1MB
  26. ]
  27. }
  28. export const uploadSingleFileRules = (msg) => {
  29. return [(v) => !!v || msg.fileRequired, (v) => !v || v.size < 1000000 || msg.fileLessThan1MB]
  30. }
  31. // Rules for user.
  32. export const passwordRules = (msg) => {
  33. return [
  34. (v) => !!v || msg.passwordRequired,
  35. (v) => (v && v.length <= 30) || msg.passwordLessThan30Chars
  36. ]
  37. }
  38. export const templateNameRules = () => {
  39. return [(v) => !!v || 'Name is required']
  40. }