From 0144a98b3b1cd7eeda97418677c43062fce492dc Mon Sep 17 00:00:00 2001 From: cmeng Date: Tue, 12 Mar 2024 17:19:45 +1300 Subject: [PATCH] fix(edge-stack): deploy button is disabled EE-6819 (#11354) --- app/react-tools/withFormValidation.ts | 35 ++++++++++++--------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/app/react-tools/withFormValidation.ts b/app/react-tools/withFormValidation.ts index 74f0442fa..90ab64289 100644 --- a/app/react-tools/withFormValidation.ts +++ b/app/react-tools/withFormValidation.ts @@ -111,7 +111,6 @@ function createFormValidatorController( this.handleChange = this.handleChange.bind(this); this.runValidation = this.runValidation.bind(this); - this.validate = this.validate.bind(this); } async handleChange(newValues: TFormModel) { @@ -126,7 +125,7 @@ function createFormValidatorController( this.form?.$setValidity('form', true, this.form); const schema = schemaBuilder(this.validationData); - this.errors = await this.validate(schema, value, isPrimitive); + this.errors = await validate(schema, value, isPrimitive); if (this.errors && Object.keys(this.errors).length > 0) { this.form?.$setValidity('form', false, this.form); @@ -134,23 +133,6 @@ function createFormValidatorController( }); } - async validate( - schema: SchemaOf, - value: TFormModel, - isPrimitive: boolean - ): Promise> { - return this.$async(async () => { - if (isPrimitive) { - const result = await validateForm<{ value: TFormModel }>( - () => object({ value: schema }), - { value } - ); - return result?.value as ValidationResult; - } - return validateForm(() => schema, value); - }); - } - async $onChanges(changes: { values?: { currentValue: TFormModel }; validationData?: { currentValue: TData }; @@ -165,3 +147,18 @@ function createFormValidatorController( } }; } + +async function validate( + schema: SchemaOf, + value: TFormModel, + isPrimitive: boolean +): Promise> { + if (isPrimitive) { + const result = await validateForm<{ value: TFormModel }>( + () => object({ value: schema }), + { value } + ); + return result?.value as ValidationResult; + } + return validateForm(() => schema, value); +}