Commit f1b85f3b authored by MARCO Jonathan's avatar MARCO Jonathan
Browse files

ūüźõ Fix the number second validation

parent 9888e443
Pipeline #64506 passed with stage
in 15 seconds
<template>
<v-text-field
v-if="editorMode || exist"
v-show="editorMode || visible"
:id="field.id"
:key="key"
v-model="value"
:class="editorMode ? 'mx-2' : ''"
:type="field.type"
:label="label"
:placeholder="translated(fieldId, 'placeholder')"
:hint="translated(fieldId, 'hint')"
:persistent-hint="field.persistentHint"
:prefix="translated(fieldId, 'prefix')"
:suffix="translated(fieldId, 'suffix')"
:prepend-icon="field.prependIcon"
:append-icon="field.appendIcon"
:filled="field.filled"
:outlined="field.outlined"
:rounded="field.rounded"
:shaped="field.shaped"
:clearable="field.clearable"
:rules="rules"
:disabled="fieldOnReadOnly"
v-if="editorMode || exist"
v-show="editorMode || visible"
:id="field.id"
:key="key"
v-model="value"
:class="editorMode ? 'mx-2' : ''"
:type="field.type"
:label="label"
:placeholder="translated(fieldId, 'placeholder')"
:hint="translated(fieldId, 'hint')"
:persistent-hint="field.persistentHint"
:prefix="translated(fieldId, 'prefix')"
:suffix="translated(fieldId, 'suffix')"
:prepend-icon="field.prependIcon"
:append-icon="field.appendIcon"
:filled="field.filled"
:outlined="field.outlined"
:rounded="field.rounded"
:shaped="field.shaped"
:clearable="field.clearable"
:rules="rules"
:disabled="fieldOnReadOnly"
>
<template #append-outer>
<v-icon
v-if="field.repeatable"
@click="repeat"
v-if="field.repeatable"
@click="repeat"
>
mdi-plus
</v-icon>
......@@ -35,7 +35,7 @@
</template>
<script lang="ts">
import { usfFieldMixin, usfHandleConditional, usfDefaultTokenMixin } from '@form-plugin/mixins';
import {usfFieldMixin, usfHandleConditional, usfDefaultTokenMixin} from '@form-plugin/mixins';
import Vue from 'vue';
export default Vue.extend({
......@@ -68,13 +68,13 @@ export default Vue.extend({
},
minErrorMessage(): string {
return this.field.type === 'number'
? `${this.field.label} doit être supérieur ou égal à ${this.field.min}`
: `${this.field.label} doit comporter ${this.field.min} caractères ou plus`;
? `${this.field.label} doit être supérieur ou égal à ${this.field.min}`
: `${this.field.label} doit comporter ${this.field.min} caractères ou plus`;
},
maxErrorMessage(): string {
return this.field.type === 'number'
? `${this.field.label} doit être inférieur ou égal à ${this.field.max}`
: `${this.field.label} doit comporter ${this.field.max} caractères ou moins`;
? `${this.field.label} doit être inférieur ou égal à ${this.field.max}`
: `${this.field.label} doit comporter ${this.field.max} caractères ou moins`;
},
},
......@@ -87,35 +87,38 @@ export default Vue.extend({
methods: {
handleMin(): boolean | string {
const test = this.field.type === 'number'
? (!!this.value && parseFloat(this.value) >= parseFloat(this.field.min))
: (!!this.value && this.value.length >= this.field.min);
? (!!this.value && parseFloat(this.value) >= parseFloat(this.field.min))
: (!!this.value && this.value.length >= this.field.min);
return this.editorMode
|| !this.field.min
|| !this.value
|| test
|| this.minErrorMessage;
|| !this.field.min
|| !this.value
|| test
|| this.minErrorMessage;
},
handleMax(): boolean | string {
const test = this.field.type === 'number'
? (!!this.value && parseFloat(this.value) <= parseFloat(this.field.max))
: (!!this.value && this.value.length <= this.field.max);
? (!!this.value && parseFloat(this.value) <= parseFloat(this.field.max))
: (!!this.value && this.value.length <= this.field.max);
return this.editorMode
|| !this.field.max
|| !this.value
|| test
|| this.maxErrorMessage;
|| !this.field.max
|| !this.value
|| test
|| this.maxErrorMessage;
},
handleEmail(): boolean | string {
return this.editorMode
|| !this.value
|| /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(this.value) // eslint-disable-line no-useless-escape
|| 'Veuillez saisir une adresse électronique valide';
|| !this.value
|| /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(this.value) // eslint-disable-line no-useless-escape
|| 'Veuillez saisir une adresse électronique valide';
},
numberTypeError(): boolean | string {
return this.value === undefined || !isNaN(parseFloat(this.value)) || 'La valeur doit être un nombre';
return this.value === undefined
|| this.value === null
|| !isNaN(parseFloat(this.value))
|| 'La valeur doit être un nombre';
},
},
});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment