Browse Source

Giving rule keys semantically meaningful names

pull/976/head
Collin Brown 4 years ago
parent
commit
37a23c795a
3 changed files with 48 additions and 48 deletions
  1. 32
      frontend/i18n/en/rules.js
  2. 32
      frontend/i18n/fr/rules.js
  3. 32
      frontend/rules/index.js

32
frontend/i18n/en/rules.js

@ -1,38 +1,38 @@
export default {
colorRules: {
rule1: 'Color is required'
colorRequired: 'Color is required'
},
labelNameRules: {
rule1: 'Label name is required',
rule2: 'Label name must be less than 30 characters'
labelRequied: 'Label name is required',
labelLessThan30Chars: 'Label name must be less than 30 characters'
},
userNameRules: {
rule1: 'User name is required',
rule2: 'User name must be less than 30 characters'
userNameRequired: 'User name is required',
userNameLessThan30Chars: 'User name must be less than 30 characters'
},
roleRules: {
rule1: 'Role is required'
roleRequired: 'Role is required'
},
projectNameRules: {
rule1: 'Project name is required',
rule2: 'Project name must be less than 30 characters'
projectNameRequired: 'Project name is required',
projectNameLessThan30Chars: 'Project name must be less than 30 characters'
},
descriptionRules: {
rule1: 'Description is required',
rule2: 'Description must be less than 100 characters'
descriptionRequired: 'Description is required',
descriptionLessThan30Chars: 'Description must be less than 100 characters'
},
projectTypeRules: {
rule1: 'Project type is required'
projectTypeRequired: 'Project type is required'
},
fileFormatRules: {
rule1: 'File format is required'
fileFormatRequired: 'File format is required'
},
uploadFileRules: {
rule1: 'File is required',
rule2: 'File size should be less than 1 MB!'
fileRequired: 'File is required',
fileLessThan1MB: 'File size should be less than 1 MB!'
},
passwordRules: {
rule1: 'Password is required',
rule2: 'Password must be less than 30 characters'
passwordRequired: 'Password is required',
passwordLessThan30Chars: 'Password must be less than 30 characters'
}
}

32
frontend/i18n/fr/rules.js

@ -1,38 +1,38 @@
export default {
colorRules: {
rule1: 'La couleur est obligatoire'
colorRequired: 'La couleur est obligatoire'
},
labelNameRules: {
rule1: 'Le nom de l\'étiquette est obligatoire',
rule2: 'Le nom de l\'étiquette doit comporter moins de 30 caractères'
labelRequied: 'Le nom de l\'étiquette est obligatoire',
labelLessThan30Chars: 'Le nom de l\'étiquette doit comporter moins de 30 caractères'
},
userNameRules: {
rule1: 'Le nom d\'utilisateur est requis',
rule2: 'Le nom d\'utilisateur doit comporter moins de 30 caractères'
userNameRequired: 'Le nom d\'utilisateur est requis',
userNameLessThan30Chars: 'Le nom d\'utilisateur doit comporter moins de 30 caractères'
},
roleRules: {
rule1: 'Rôle est obligatoire'
roleRequired: 'Rôle est obligatoire'
},
projectNameRules: {
rule1: 'Le nom du projet est requis',
rule2: 'Le nom du projet doit comporter moins de 30 caractères'
projectNameRequired: 'Le nom du projet est requis',
projectNameLessThan30Chars: 'Le nom du projet doit comporter moins de 30 caractères'
},
descriptionRules: {
rule1: 'Une description est requise',
rule2: 'La description doit comporter moins de 100 caractères'
descriptionRequired: 'Une description est requise',
descriptionLessThan30Chars: 'La description doit comporter moins de 100 caractères'
},
projectTypeRules: {
rule1: 'Le type de projet est requis'
projectTypeRequired: 'Le type de projet est requis'
},
fileFormatRules: {
rule1: 'Le format de fichier est requis'
fileFormatRequired: 'Le format de fichier est requis'
},
uploadFileRules: {
rule1: 'Le fichier est obligatoire',
rule2: 'La taille du fichier doit être inférieure à 1MB'
fileRequired: 'Le fichier est obligatoire',
fileLessThan1MB: 'La taille du fichier doit être inférieure à 1MB'
},
passwordRules: {
rule1: 'Le mot de passe est obligatoire',
rule2: 'Le mot de passe doit comporter moins de 30 caractères'
passwordRequired: 'Le mot de passe est obligatoire',
passwordLessThan30Chars: 'Le mot de passe doit comporter moins de 30 caractères'
}
}

32
frontend/rules/index.js

@ -1,70 +1,70 @@
// Rules for project label.
export const colorRules = (msg) => {
return [
v => !!v || msg.rule1
v => !!v || msg.colorRequired
]
}
export const labelNameRules = (msg) => {
return [
v => !!v || msg.rule1,
v => (v && v.length <= 30) || msg.rule2
v => !!v || msg.labelRequired,
v => (v && v.length <= 30) || msg.labelLessThan30Chars
]
}
// Rules for project member.
export const userNameRules = (msg) => {
return [
v => !!v || msg.rule1,
v => (v && v.length <= 30) || msg.rule2
v => !!v || msg.userNameRequired,
v => (v && v.length <= 30) || msg.userNameLessThan30Chars
]
}
export const roleRules = (msg) => {
return [
v => !!v || msg.rule1
v => !!v || msg.roleRequired
]
}
// Rules for a project.
export const projectNameRules = (msg) => {
return [
v => !!v || msg.rule1,
v => (v && v.length <= 30) || msg.rule2
v => !!v || msg.projectNameRequired,
v => (v && v.length <= 30) || msg.projectNameLessThan30Chars
]
}
export const descriptionRules = (msg) => {
return [
v => !!v || msg.rule1,
v => (v && v.length <= 100) || msg.rule2
v => !!v || msg.descriptionRequired,
v => (v && v.length <= 100) || msg.descriptionLessThan30Chars
]
}
export const projectTypeRules = (msg) => {
return [
v => !!v || msg.rule1
v => !!v || msg.projectTypeRequired
]
}
// Rules for Document.
export const fileFormatRules = (msg) => {
return [
v => !!v || msg.rule1
v => !!v || msg.fileFormatRequired
]
}
export const uploadFileRules = (msg) => {
return [
v => !!v || msg.rule1,
v => !v || v.size < 1000000 || msg.rule2
v => !!v || msg.fileRequired,
v => !v || v.size < 1000000 || msg.fileLessThan1MB
]
}
// Rules for user.
export const passwordRules = (msg) => {
return [
v => !!v || msg.rule1,
v => (v && v.length <= 30) || msg.rule2
v => !!v || msg.passwordRequired,
v => (v && v.length <= 30) || msg.passwordLessThan30Chars
]
}
Loading…
Cancel
Save