Skip to content

Commit 7120620

Browse files
committed
Apply Copilot review suggestions.
1 parent f346aa5 commit 7120620

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

lib/core/src/lib/form/components/widgets/core/form-field-validator.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@ export class RequiredFieldValidator implements FormFieldValidator {
6969
return !!field.value;
7070
}
7171

72-
if (field.value === null || field.value === undefined || field.value === '') {
73-
return false;
74-
}
75-
76-
if (typeof field.value === 'string' && field.value.trim().length === 0) {
72+
if (field.isValueEmpty()) {
7773
return false;
7874
}
7975
}

lib/core/src/lib/form/components/widgets/core/form-field.model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export class FormFieldModel extends FormWidgetModel {
178178
return this._isValid;
179179
}
180180
}
181-
} else if (this.readOnly && this._required && !this.form?.isFieldOrParentHidden(this) && this.isValueEmpty()) {
181+
} else if (this.readOnly && this.required && !this.form?.isFieldOrParentHidden(this) && this.isValueEmpty()) {
182182
this._isValid = false;
183183
return this._isValid;
184184
}
@@ -190,7 +190,7 @@ export class FormFieldModel extends FormWidgetModel {
190190
return !this.readOnly || FormFieldTypes.isValidatableType(this.type);
191191
}
192192

193-
private isValueEmpty(): boolean {
193+
isValueEmpty(): boolean {
194194
if (this.value === null || this.value === undefined || this.value === '') {
195195
return true;
196196
}

0 commit comments

Comments
 (0)