How to use the webiny-model.Attribute.isEmptyValue function in webiny-model

To help you get started, we’ve selected a few webiny-model examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webiny / webiny-js / packages / webiny-entity / src / entityAttributes / entitiesAttribute.js View on Github external
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));
    }
github webiny / webiny-js / packages / webiny-entity / src / entityAttributes / entityAttribute.js View on Github external
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
github webiny / webiny-js / packages-utils / webiny-entity / src / entityAttributes / entitiesAttribute.js View on Github external
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));
    }
github webiny / webiny-js / packages-utils / webiny-entity / src / entityAttributes / entityAttribute.js View on Github external
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