Skip to content

Commit 3d255a0

Browse files
committed
fixed validation when non-required fields are once again blank
1 parent c7bb41d commit 3d255a0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/components/FormlyField.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
//first check if we need to create a field
1919
if ( !this.form.$errors[this.field.key] ) this.$set(this.form.$errors, this.field.key, {});
2020
if ( !this.field.templateOptions ) this.$set(this.field, 'templateOptions', {});
21-
21+
2222
//check for required fields. This whole setting,unsetting thing seems kind of wrong though..
2323
//there might be a more 'vue-ey' way to do this...
2424
if ( this.field.required ){
2525
if ( !this.form.$errors[this.field.key].required ) this.$set(this.form.$errors[ this.field.key ], 'required', true);
2626
setError(this.form, this.field.key, 'required', !this.model[ this.field.key ]) ;
2727
}
28-
28+
2929
//if we've got nothing left then return
3030
if ( !this.field.validators ) return;
3131
@@ -35,7 +35,10 @@
3535
3636
Object.keys(this.field.validators).forEach((validKey) => {
3737
if ( !this.form.$errors[this.field.key][validKey] ) this.$set(this.form.$errors[ this.field.key ], validKey, false);
38-
if ( !this.field.required && !this.model[ this.field.key ] ) return;
38+
if ( !this.field.required && !this.model[ this.field.key ] ) {
39+
setError(this.form, this.field.key, validKey, false);
40+
return;
41+
}
3942
4043
let validator = this.field.validators[validKey];
4144
let validatorMessage = false;

0 commit comments

Comments
 (0)