diff --git a/package.json b/package.json index 328f111..72e3faa 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,6 @@ }, "dependencies": { "@fortawesome/fontawesome-free": "^5.14.0", - "@types/lodash": "^4.14.172", "buefy": "^0.8.20", "bulma": "^0.9.0", "core-js": "^3.6.5", @@ -39,6 +38,7 @@ }, "devDependencies": { "@types/jest": "^26.0.10", + "@types/lodash": "^4.14.172", "@typescript-eslint/eslint-plugin": "^3.9.1", "@typescript-eslint/parser": "^3.9.1", "@vue/cli-plugin-babel": "^4.2.3", diff --git a/src/components/UiFormInputs/UiInputText/UiInputText.vue b/src/components/UiFormInputs/UiInputText/UiInputText.vue index 811e8c5..af8ecd3 100644 --- a/src/components/UiFormInputs/UiInputText/UiInputText.vue +++ b/src/components/UiFormInputs/UiInputText/UiInputText.vue @@ -36,6 +36,8 @@ :icon="icon" :minlength="min" :maxlength="max" + :min="minSize" + :max="maxSize" :validation-message="validation" :step="step" :placeholder="placeholder" @@ -57,6 +59,8 @@ @Prop({ default: 'text' }) type!: string; @Prop() min!: number; @Prop() max!: number; + @Prop() minSize!: number; + @Prop() maxSize!: number; @Prop() validation!: string; @Prop() disabled!: boolean; @Prop({ default: 'required' }) rules!: string; diff --git a/src/dependencies/i18n.messages.ts b/src/dependencies/i18n.messages.ts index 7f8cca4..e294d0e 100644 --- a/src/dependencies/i18n.messages.ts +++ b/src/dependencies/i18n.messages.ts @@ -8,6 +8,7 @@ const messages = { MIN_LENGTH_AMOUNT: 'This field should contain at least {length} characters', NO_ZERO: 'Cannot be zero', VALID_CURRENCY: 'Use valid currency format', + MAX_LENGTH_AMOUNT: 'Max {length}', ONLY_NUMBERS: 'Only numbers', SELECT_DIRECTORS: 'Please select the directors', NOT_POSSIBLE: 'Unfortunately, this is not possible.', @@ -38,6 +39,7 @@ const messages = { MIN_LENGTH_AMOUNT: 'Dit veld moet minimaal {length} karakters bevatten', NO_ZERO: 'Mag niet nul zijn', VALID_CURRENCY: 'Gebruik geldige valutanotatie', + MAX_LENGTH_AMOUNT: 'Max {length}', ONLY_NUMBERS: 'Alleen nummers', SELECT_DIRECTORS: 'Selecteer de bestuurders', NOT_POSSIBLE: 'Dit is helaas niet mogelijk.', diff --git a/src/dependencies/validators.ts b/src/dependencies/validators.ts index fdeec80..e4be940 100644 --- a/src/dependencies/validators.ts +++ b/src/dependencies/validators.ts @@ -1,5 +1,5 @@ import { extend } from 'vee-validate'; -import { confirmed, email, min, min_value, numeric, required } from 'vee-validate/dist/rules'; +import { confirmed, email, min, min_value, max_value, numeric, required } from 'vee-validate/dist/rules'; const kvk = { validate(value: string) { @@ -116,6 +116,10 @@ class Validators { ...min_value, message: () => ('NO_ZERO') }); + extend('max', { + ...max_value, + message: (_, { max }) => ({ m: 'MAX_LENGTH_AMOUNT', length: max.toString() }) as any + }); extend('min', { ...min, message: (_, { length }) => ({ m: 'MIN_LENGTH_AMOUNT', length: length.toString() }) as any