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.

77 lines
1.6 KiB

5 years ago
5 years ago
  1. // Rules for project label.
  2. export const colorRules = (msg) => {
  3. return [
  4. v => !!v || msg.colorRequired
  5. ]
  6. }
  7. export const labelNameRules = (msg) => {
  8. return [
  9. v => !!v || msg.labelRequired,
  10. v => (v && v.length <= 30) || msg.labelLessThan30Chars
  11. ]
  12. }
  13. // Rules for project member.
  14. export const userNameRules = (msg) => {
  15. return [
  16. v => !!v || msg.userNameRequired,
  17. v => (v && v.length <= 30) || msg.userNameLessThan30Chars
  18. ]
  19. }
  20. export const roleRules = (msg) => {
  21. return [
  22. v => !!v || msg.roleRequired
  23. ]
  24. }
  25. // Rules for a project.
  26. export const projectNameRules = (msg) => {
  27. return [
  28. v => !!v || msg.projectNameRequired,
  29. v => (v && v.length <= 30) || msg.projectNameLessThan30Chars
  30. ]
  31. }
  32. export const descriptionRules = (msg) => {
  33. return [
  34. v => !!v || msg.descriptionRequired,
  35. v => (v && v.length <= 100) || msg.descriptionLessThan30Chars
  36. ]
  37. }
  38. export const projectTypeRules = (msg) => {
  39. return [
  40. v => !!v || msg.projectTypeRequired
  41. ]
  42. }
  43. // Rules for Document.
  44. export const fileFormatRules = (msg) => {
  45. return [
  46. v => !!v || msg.fileFormatRequired
  47. ]
  48. }
  49. export const uploadFileRules = (msg) => {
  50. return [
  51. v => !!v || msg.fileRequired,
  52. v => !v || v.some(file => file.size < 100000000) || msg.fileLessThan1MB
  53. ]
  54. }
  55. export const uploadSingleFileRules = (msg) => {
  56. return [
  57. v => !!v || msg.fileRequired,
  58. v => !v || v.size < 1000000 || msg.fileLessThan1MB
  59. ]
  60. }
  61. // Rules for user.
  62. export const passwordRules = (msg) => {
  63. return [
  64. v => !!v || msg.passwordRequired,
  65. v => (v && v.length <= 30) || msg.passwordLessThan30Chars
  66. ]
  67. }