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

pull/11368/head
cmeng 9 months ago committed by GitHub
parent 64a08c59e9
commit 0144a98b3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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);
}

Loading…
Cancel
Save