From 45129624128d5d820cdd8c5571848c7b682e129b Mon Sep 17 00:00:00 2001 From: Axolotle Date: Fri, 23 Oct 2020 17:40:12 +0200 Subject: [PATCH] update deps, install vuelidate and add custom validators --- app/package.json | 14 ++++++++------ .../helpers/validators/customValidators.js | 19 +++++++++++++++++++ app/src/helpers/validators/index.js | 3 +++ 3 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 app/src/helpers/validators/customValidators.js create mode 100644 app/src/helpers/validators/index.js diff --git a/app/package.json b/app/package.json index 7e5e3551..c0fe19aa 100644 --- a/app/package.json +++ b/app/package.json @@ -11,20 +11,21 @@ "i18n:report": "vue-cli-service i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'" }, "dependencies": { - "bootstrap-vue": "^2.17.3", + "bootstrap-vue": "^2.18.1", "core-js": "^3.6.5", "date-fns": "^2.16.1", "fork-awesome": "^1.1.7", "vue": "^2.6.12", - "vue-i18n": "^8.21.1", - "vue-router": "^3.4.5", + "vue-i18n": "^8.22.1", + "vue-router": "^3.4.7", + "vuelidate": "^0.7.5", "vuex": "^3.4.0" }, "devDependencies": { "@vue/cli-plugin-babel": "~4.4.0", "@vue/cli-plugin-eslint": "~4.4.0", - "@vue/cli-plugin-router": "^4.5.6", - "@vue/cli-plugin-vuex": "^4.5.6", + "@vue/cli-plugin-router": "^4.5.8", + "@vue/cli-plugin-vuex": "^4.5.8", "@vue/cli-service": "~4.4.0", "babel-eslint": "^10.1.0", "bootstrap": "^4.5.2", @@ -66,7 +67,8 @@ ], "template-curly-spacing": "off", "indent": "off", - "no-irregular-whitespace": "off" + "no-irregular-whitespace": "off", + "no-unused-vars": "warn" } }, "browserslist": [ diff --git a/app/src/helpers/validators/customValidators.js b/app/src/helpers/validators/customValidators.js new file mode 100644 index 00000000..1d9c0e54 --- /dev/null +++ b/app/src/helpers/validators/customValidators.js @@ -0,0 +1,19 @@ +import { helpers } from 'vuelidate/lib/validators' + +const alphalownum_ = helpers.regex('alphalownum_', /^[a-z0-9_]+$/) + +const includes = items => item => helpers.withParams( + { type: 'includes', value: item }, (item) => { + return items ? items.includes(item) : false +})(item) + +const unique = items => item => helpers.withParams( + { type: 'unique', arg: items, value: item }, + item => items ? !items.includes(item) : true +)(item) + +export { + alphalownum_, + includes, + unique +} diff --git a/app/src/helpers/validators/index.js b/app/src/helpers/validators/index.js new file mode 100644 index 00000000..3cd51a49 --- /dev/null +++ b/app/src/helpers/validators/index.js @@ -0,0 +1,3 @@ +// helper module to expose custom and vuelidate validators. +export * from 'vuelidate/lib/validators' +export * from './customValidators'