How to use the @webiny/commodo.boolean function in @webiny/commodo

To help you get started, we’ve selected a few @webiny/commodo 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 / api-files / src / plugins / models / filesSettings.model.js View on Github external
withStaticProps({
            async load() {
                let settings = await this.findOne({ query: { key: SETTINGS_KEY } });
                if (!settings) {
                    settings = new FilesSettings();
                    await settings.save();
                }
                return settings;
            }
        }),
        withFields({
            key: setOnce()(string({ value: SETTINGS_KEY })),
            data: fields({
                value: {},
                instanceOf: withFields({
                    installed: boolean({ value: false }),
                    srcPrefix: onSet(value => {
                        // Make sure srcPrefix always ends with forward slash.
                        if (typeof value === "string") {
                            return value.endsWith("/") ? value : value + "/";
                        }
                        return value;
                    })(
                        string({
                            validation: validation.create("required"),
                            value: "/files/"
                        })
                    )
                })()
            })
        })
    )(createBase());
github webiny / webiny-js / packages / api-mailchimp / src / mailchimpSettings.model.js View on Github external
withFields(instance => ({
            key: setOnce()(string({ value: SETTINGS_KEY })),
            data: fields({
                instanceOf: withFields({
                    enabled: boolean(),
                    apiKey: onSet(value => {
                        if (value && value !== instance.apiKey) {
                            instance.registerHookCallback("beforeSave", async () => {
                                console.log("TODO: setOnce");

                                const mailchimp = new MailchimpApi({ apiKey: value });
                                const valid = await mailchimp.isValidApiKey();
                                if (!valid) {
                                    throw Error("API key invalid.");
                                }
                            });
                        }
                        return value;
                    })(string())
                })()
            })
github webiny / webiny-js / packages / api-security / src / plugins / models / securityRole.model.js View on Github external
export default ({ createBase }) => {
    const SecurityRole = flow(
        withName("SecurityRole"),
        withFields({
            name: string(),
            slug: string(),
            description: string(),
            system: boolean(),
            scopes: string({ list: true })
        }),
        withHooks({
            async beforeCreate() {
                const existingRole = await SecurityRole.findOne({
                    query: { slug: this.slug }
                });
                if (existingRole) {
                    throw Error(`Role with slug "${this.slug}" already exists.`);
                }
            },
            async beforeDelete() {
                if (this.system) {
                    throw Error(`Cannot delete system role.`);
                }
            }
github webiny / webiny-js / packages / api-page-builder / src / plugins / models / pbSettings.model.js View on Github external
const step = () =>
    fields({
        value: {},
        instanceOf: flow(
            withFields({
                started: boolean({ value: false }),
                startedOn: date(),
                completed: boolean({ value: false }),
                completedOn: date()
            }),
            withProps({
                markAsStarted() {
                    this.started = true;
                    this.startedOn = new Date();
                },
                markAsCompleted() {
                    this.completed = true;
                    this.completedOn = new Date();
                }
            })
        )()
    });
github webiny / webiny-js / packages / api-page-builder / src / plugins / models / pbSettings.model.js View on Github external
const step = () =>
    fields({
        value: {},
        instanceOf: flow(
            withFields({
                started: boolean({ value: false }),
                startedOn: date(),
                completed: boolean({ value: false }),
                completedOn: date()
            }),
            withProps({
                markAsStarted() {
                    this.started = true;
                    this.startedOn = new Date();
                },
                markAsCompleted() {
                    this.completed = true;
                    this.completedOn = new Date();
                }
            })
        )()
    });
github webiny / webiny-js / packages / api-google-tag-manager / src / googleTagManagerSettings.model.js View on Github external
export default ({ createBase }) => {
    return flow(
        withName("Settings"),
        withStaticProps({
            async load() {
                return await this.findOne({ query: { key: SETTINGS_KEY } });
            }
        }),
        withFields({
            key: setOnce()(string({ value: SETTINGS_KEY })),
            data: fields({
                instanceOf: withFields({
                    enabled: boolean(),
                    code: string()
                })()
            })
        })
    )(createBase());
};
github webiny / webiny-js / packages / api-cookie-policy / src / cookiePolicySettings.model.js View on Github external
background: string(),
        text: string()
    })();

    return flow(
        withName("Settings"),
        withStaticProps({
            async load() {
                return await this.findOne({ query: { key: SETTINGS_KEY } });
            }
        }),
        withFields({
            key: setOnce()(string({ value: SETTINGS_KEY })),
            data: fields({
                instanceOf: withFields({
                    enabled: boolean(),
                    position: string({
                        value: "bottom",
                        validation: validation.create("in:bottom:top:bottom-left:bottom-right")
                    }),
                    palette: fields({
                        instanceOf: withFields({
                            popup: fields({ instanceOf: ColorsModel }),
                            button: fields({ instanceOf: ColorsModel })
                        })()
                    }),
                    content: fields({
                        instanceOf: withFields({
                            href: string(),
                            message: string(),
                            dismiss: string(),
                            link: string()
github webiny / webiny-js / packages / api-security / src / plugins / models / securityGroup.model.js View on Github external
withFields(() => ({
            description: string(),
            name: string(),
            slug: string(),
            system: boolean(),
            roles: ref({
                list: true,
                instanceOf: [SecurityRole, "model"],
                using: [SecurityRoles2Models, "role"]
            })
        })),
        withHooks({
github webiny / webiny-js / packages / api-forms / src / plugins / models / Form / createSettingsModel.js View on Github external
get siteKey() {
                            return new Promise(async resolve => {
                                const settings = await FormSettings.load();
                                resolve(get(settings, "data.reCaptcha.siteKey"));
                            });
                        },
                        get secretKey() {
                            return new Promise(async resolve => {
                                const settings = await FormSettings.load();
                                resolve(get(settings, "data.reCaptcha.secretKey"));
                            });
                        }
                    }
                }),
                withFields({
                    enabled: boolean(),
                    errorMessage: i18nString({
                        context,
                        value: {
                            values: [
                                {
                                    locale: defaultLocale,
                                    value: "Please verify that you are not a robot."
                                }
                            ]
                        }
                    })
                })
            )(),
            value: {}
        })
    })();