Browse Source

Validate description field

pull/2093/head
Hironsan 2 years ago
parent
commit
3412956239
6 changed files with 10 additions and 35 deletions
  1. 9
      frontend/components/project/ProjectDescriptionField.vue
  2. 6
      frontend/i18n/de/rules.js
  3. 6
      frontend/i18n/en/rules.js
  4. 6
      frontend/i18n/fr/rules.js
  5. 6
      frontend/i18n/zh/rules.js
  6. 12
      frontend/rules/index.js

9
frontend/components/project/ProjectDescriptionField.vue

@ -2,7 +2,7 @@
<v-text-field
v-bind="$attrs"
:value="value"
:rules="descriptionRules($t('rules.descriptionRules'))"
:rules="descriptionRules"
:label="$t('generic.description')"
required
@input="$emit('input', $event)"
@ -10,8 +10,8 @@
</template>
<script lang="ts">
import { descriptionRules } from '@/rules/index'
import Vue from 'vue'
import { isEmptyText } from '~/domain/models/project/project'
export default Vue.extend({
props: {
@ -23,7 +23,10 @@ export default Vue.extend({
},
data() {
return {
descriptionRules
descriptionRules: [
(text: string) =>
!isEmptyText(text) || this.$t('rules.descriptionRules.descriptionRequired')
]
}
}
})

6
frontend/i18n/de/rules.js

@ -18,11 +18,7 @@ export default {
projectNameLessThan100Chars: 'Projektname muss kürzer als 100 Zeichen sein'
},
descriptionRules: {
descriptionRequired: 'Beschreibung wird benötigt',
descriptionLessThan30Chars: 'Beschreibung muss kürzer als 100 Zeichen sein'
},
projectTypeRules: {
projectTypeRequired: 'Projekttyp wird benötigt'
descriptionRequired: 'Beschreibung wird benötigt'
},
fileFormatRules: {
fileFormatRequired: 'Dateiformat wird benötigt'

6
frontend/i18n/en/rules.js

@ -22,11 +22,7 @@ export default {
projectNameLessThan100Chars: 'Project name must be less than 100 characters'
},
descriptionRules: {
descriptionRequired: 'Description is required',
descriptionLessThan30Chars: 'Description must be less than 100 characters'
},
projectTypeRules: {
projectTypeRequired: 'Project type is required'
descriptionRequired: 'Description is required'
},
fileFormatRules: {
fileFormatRequired: 'File format is required'

6
frontend/i18n/fr/rules.js

@ -22,11 +22,7 @@ export default {
projectNameLessThan100Chars: 'Le nom du projet doit comporter moins de 100 caractères'
},
descriptionRules: {
descriptionRequired: 'Une description est requise',
descriptionLessThan30Chars: 'La description doit comporter moins de 100 caractères'
},
projectTypeRules: {
projectTypeRequired: 'Le type de projet est requis'
descriptionRequired: 'Une description est requise'
},
fileFormatRules: {
fileFormatRequired: 'Le format de fichier est requis'

6
frontend/i18n/zh/rules.js

@ -22,11 +22,7 @@ export default {
projectNameLessThan100Chars: '项目名称必须少于100个字符'
},
descriptionRules: {
descriptionRequired: '请输入描述',
descriptionLessThan30Chars: '描述必须少于100个字符'
},
projectTypeRules: {
projectTypeRequired: '请输入项目类型'
descriptionRequired: '请输入描述'
},
fileFormatRules: {
fileFormatRequired: '请输入文件类型'

12
frontend/rules/index.js

@ -19,18 +19,6 @@ export const roleRules = (msg) => {
return [(v) => !!v || msg.roleRequired]
}
// Rules for a project.
export const descriptionRules = (msg) => {
return [
(v) => !!v || msg.descriptionRequired,
(v) => (v && v.length <= 100) || msg.descriptionLessThan30Chars
]
}
export const projectTypeRules = (msg) => {
return [(v) => !!v || msg.projectTypeRequired]
}
// Rules for Document.
export const fileFormatRules = (msg) => {
return [(v) => !!v || msg.fileFormatRequired]

Loading…
Cancel
Save