Skip to content

Commit 3499619

Browse files
committed
Merge branch 'master' into production
2 parents 9149dcb + 887c798 commit 3499619

File tree

7 files changed

+25
-8
lines changed

7 files changed

+25
-8
lines changed

src/fields/core/FieldCheckbox.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ const onFieldValueChanged = ({ target }) => {
4949
emits('onInput', target.checked)
5050
}
5151
52-
defineExpose({ hint, noLabel: true })
52+
defineExpose({ hint, noLabel: true, errors })
5353
</script>

src/fields/core/FieldChecklist.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@ const onFieldValueChanged = ({ target }) => {
6161
})
6262
}
6363
64-
defineExpose({ hint })
64+
defineExpose({ hint, errors })
6565
</script>

src/fields/core/FieldMask.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,5 @@ onBeforeMount(() => {
7676
}
7777
})
7878
79-
defineExpose({ unmaskedValue, hint })
79+
defineExpose({ unmaskedValue, hint, errors })
8080
</script>

src/fields/core/FieldNumber.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@ const onFieldValueChanged = ({ target }) => {
5959
emits('onInput', parseFloat(target.value))
6060
}
6161
62-
defineExpose({ hint })
62+
defineExpose({ hint, errors })
6363
</script>

src/fields/core/FieldPassword.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,5 @@ const onBlur = () => {
7979
})
8080
}
8181
82-
defineExpose({ hint })
82+
defineExpose({ hint, errors })
8383
</script>

src/fields/core/FieldTextarea.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ const { field, model } = toRefs(props)
3434
3535
const { isRequired, isDisabled, isReadonly, hint } = useFieldAttributes(model.value, field.value)
3636
const { currentModelValue } = useFormModel(model.value, field.value)
37-
const { validate } = useFieldValidate(model.value, field.value)
37+
const { validate, errors } = useFieldValidate(model.value, field.value)
3838
3939
const onBlur = () => {
40-
validate().then((validationErrors) => {
40+
validate(currentModelValue.value).then((validationErrors) => {
4141
emits('validated',
4242
validationErrors.length === 0,
4343
validationErrors,
@@ -47,8 +47,9 @@ const onBlur = () => {
4747
}
4848
4949
const onFieldValueChanged = (event) => {
50+
errors.value = []
5051
emits('onInput', event.target.value)
5152
}
5253
53-
defineExpose({ hint })
54+
defineExpose({ hint, errors })
5455
</script>

tests/components/fields/FieldPassword.spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,20 @@ describe('FieldPassword', () => {
112112
expect(wrapper.vm.errors.length).toBe(1)
113113
})
114114

115+
it('Should display error, with minimum length 3', async () => {
116+
const schema = { ...form.schema }
117+
const validator = (value) => value.length >= 3
118+
schema.fields[0].validator = [ validator ]
119+
120+
const formWrapper = mountFormGenerator(schema, form.model)
121+
const wrapper = formWrapper.findComponent(FieldPassword)
122+
const input = wrapper.find('input[type=password]')
123+
await input.setValue('aa')
124+
await input.trigger('blur')
125+
expect(wrapper.vm.errors.length).toBe(1)
126+
const errorContainer = formWrapper.find('.errors')
127+
expect(errorContainer.exists()).toBeTruthy()
128+
expect(errorContainer.find('.error').element.innerHTML).toBe('Field is invalid')
129+
})
130+
115131
})

0 commit comments

Comments
 (0)