Fix required validator went missing if a regex validator was added

This commit is contained in:
nathan 2023-03-08 11:00:27 -07:00
parent 09c219679a
commit b703e2bfe5
2 changed files with 2 additions and 2 deletions

View File

@ -222,7 +222,7 @@ const Et2InputWidgetMixin = <T extends Constructor<LitElement>>(superclass : T)
if(changedProperties.has('required')) if(changedProperties.has('required'))
{ {
// Remove all existing Required validators (avoids duplicates) // Remove all existing Required validators (avoids duplicates)
this.validators = (this.validators || []).filter((validator) => validator instanceof Required) this.validators = (this.validators || []).filter((validator) => !(validator instanceof Required))
if(this.required) if(this.required)
{ {
this.validators.push(new Required()); this.validators.push(new Required());

View File

@ -76,7 +76,7 @@ export class Et2Textbox extends Et2InputWidget(SlInput)
if(changedProperties.has('validator')) if(changedProperties.has('validator'))
{ {
// Remove all existing Pattern validators (avoids duplicates) // Remove all existing Pattern validators (avoids duplicates)
this.validators = (this.validators || []).filter((validator) => validator instanceof Regex) this.validators = (this.validators || []).filter((validator) => !(validator instanceof Regex))
this.validators.push(new Regex(this.validator)); this.validators.push(new Regex(this.validator));
} }
} }