Skip to content

Commit

Permalink
Merge pull request #2 from legalthings/feature/numbers
Browse files Browse the repository at this point in the history
Improved support for numbers
  • Loading branch information
theonelucas authored Aug 9, 2021
2 parents b454058 + 2c0d648 commit 7140098
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions src/components/UiFormInputs/UiInputText/UiInputText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
:icon="icon"
:minlength="min"
:maxlength="max"
:min="minSize"
:max="maxSize"
:validation-message="validation"
:step="step"
:placeholder="placeholder"
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/dependencies/i18n.messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down Expand Up @@ -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.',
Expand Down
6 changes: 5 additions & 1 deletion src/dependencies/validators.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7140098

Please sign in to comment.