Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async validate() {
const valueInstance = ((this.value: any): EntitiesAttributeValue);
// If attribute has validators or loading is in progress, wait until loaded.
const mustValidate =
valueInstance.isDirty() || this.hasValidators() || valueInstance.isLoading();
if (!mustValidate) {
return;
}
await valueInstance.load();
const value = await this.getValidationValue();
const valueValidation = !Attribute.isEmptyValue(value);
valueValidation && (await this.validateType(value));
await this.validateAttribute(value);
valueValidation && (await this.validateValue(value));
}
async validate() {
// If attribute is dirty, has validators or loading is in progress, wait until loaded.
const valueInstance = ((this.value: any): EntityAttributeValue);
if (valueInstance.isDirty() || this.hasValidators() || valueInstance.isLoading()) {
await valueInstance.load();
}
if (!valueInstance.isLoaded()) {
return;
}
const value = await this.getValidationValue();
const valueValidation = !Attribute.isEmptyValue(value);
if (valueValidation && this.hasMultipleEntityClasses()) {
if (!this.options.classIdAttribute) {
throw new ModelError(
`Entity attribute "${
this.name
}" accepts multiple Entity classes but does not have "classIdAttribute" option defined.`,
ModelError.INVALID_ATTRIBUTE
);
}
let classIdAttribute = this.getClassIdAttribute();
if (!classIdAttribute) {
throw new ModelError(
`Entity attribute "${
this.name
async validate() {
// If attribute has validators or loading is in progress, wait until loaded.
const mustValidate = this.value.isDirty() || this.hasValidators() || this.value.isLoading();
if (!mustValidate) {
return;
}
await this.value.load();
const value = await this.getValidationValue();
const valueValidation = !Attribute.isEmptyValue(value);
valueValidation && (await this.validateType(value));
await this.validateAttribute(value);
valueValidation && (await this.validateValue(value));
}
async validate() {
// If attribute is dirty, has validators or loading is in progress, wait until loaded.
if (this.value.isDirty() || this.hasValidators() || this.value.isLoading()) {
await this.value.load();
}
if (!this.value.isLoaded()) {
return;
}
const value = await this.getValidationValue();
const valueValidation = !Attribute.isEmptyValue(value);
if (valueValidation && this.hasMultipleEntityClasses()) {
if (!this.options.classIdAttribute) {
throw new ModelError(
`Entity attribute "${
this.name
}" accepts multiple Entity classes but does not have "classIdAttribute" option defined.`,
ModelError.INVALID_ATTRIBUTE
);
}
let classIdAttribute = this.getClassIdAttribute();
if (!classIdAttribute) {
throw new ModelError(
`Entity attribute "${
this.name