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.

67 lines
1.7 KiB

2 years ago
2 years ago
2 years ago
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 a project.
  19. export const projectNameRules = (msg) => {
  20. return [
  21. (v) => !!v || msg.projectNameRequired,
  22. (v) => (v && v.length <= 30) || msg.projectNameLessThan30Chars
  23. ]
  24. }
  25. export const descriptionRules = (msg) => {
  26. return [
  27. (v) => !!v || msg.descriptionRequired,
  28. (v) => (v && v.length <= 100) || msg.descriptionLessThan30Chars
  29. ]
  30. }
  31. export const projectTypeRules = (msg) => {
  32. return [(v) => !!v || msg.projectTypeRequired]
  33. }
  34. // Rules for Document.
  35. export const fileFormatRules = (msg) => {
  36. return [(v) => !!v || msg.fileFormatRequired]
  37. }
  38. export const uploadFileRules = (msg) => {
  39. return [
  40. (v) => !!v || msg.fileRequired,
  41. (v) => !v || v.some((file) => file.size < 100000000) || msg.fileLessThan1MB
  42. ]
  43. }
  44. export const uploadSingleFileRules = (msg) => {
  45. return [(v) => !!v || msg.fileRequired, (v) => !v || v.size < 1000000 || msg.fileLessThan1MB]
  46. }
  47. // Rules for user.
  48. export const passwordRules = (msg) => {
  49. return [
  50. (v) => !!v || msg.passwordRequired,
  51. (v) => (v && v.length <= 30) || msg.passwordLessThan30Chars
  52. ]
  53. }
  54. export const templateNameRules = () => {
  55. return [(v) => !!v || 'Name is required']
  56. }