fix(edge-stack): deploy button is disabled EE-6819 (#11355)

pull/11367/head
cmeng 2024-03-12 17:19:42 +13:00 committed by GitHub
parent 71292a60b1
commit 447f497506
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 19 deletions

View File

@ -111,7 +111,6 @@ function createFormValidatorController<TFormModel, TData = never>(
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<TFormModel, TData = never>(
this.form?.$setValidity('form', true, this.form);
const schema = schemaBuilder(this.validationData);
this.errors = await this.validate(schema, value, isPrimitive);
this.errors = await validate<TFormModel>(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<TFormModel, TData = never>(
});
}
async validate(
schema: SchemaOf<TFormModel>,
value: TFormModel,
isPrimitive: boolean
): Promise<ValidationResult<TFormModel>> {
return this.$async(async () => {
if (isPrimitive) {
const result = await validateForm<{ value: TFormModel }>(
() => object({ value: schema }),
{ value }
);
return result?.value as ValidationResult<TFormModel>;
}
return validateForm<TFormModel>(() => schema, value);
});
}
async $onChanges(changes: {
values?: { currentValue: TFormModel };
validationData?: { currentValue: TData };
@ -165,3 +147,18 @@ function createFormValidatorController<TFormModel, TData = never>(
}
};
}
async function validate<TFormModel>(
schema: SchemaOf<TFormModel>,
value: TFormModel,
isPrimitive: boolean
): Promise<ValidationResult<TFormModel>> {
if (isPrimitive) {
const result = await validateForm<{ value: TFormModel }>(
() => object({ value: schema }),
{ value }
);
return result?.value as ValidationResult<TFormModel>;
}
return validateForm<TFormModel>(() => schema, value);
}