How to use the @webiny/commodo.string 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-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 / pbCategory.model.js View on Github external
export default ({ createBase }) =>
    flow(
        withName("PbCategory"),
        withFields({
            name: string({ validation: validation.create("required") }),
            slug: string({ validation: validation.create("required") }),
            url: string({ validation: validation.create("required") }),
            layout: string()
        })
    )(createBase());
github webiny / webiny-js / packages / api-page-builder / src / plugins / pageSettings / social.js View on Github external
apply({ fields: settingsFields, context }) {
            settingsFields.social = fields({
                value: {},
                instanceOf: withFields({
                    meta: fields({
                        value: [],
                        list: true,
                        instanceOf: withFields({
                            property: string(),
                            content: string()
                        })()
                    }),
                    title: string(),
                    description: string(),
                    image: context.commodo.fields.id()
                })()
            });
        }
    },
github webiny / webiny-js / packages / api-forms / src / plugins / models / Form / createFieldModel.js View on Github external
export default context =>
    withFields({
        _id: string({ validation: validation.create("required") }),
        type: string({ validation: validation.create("required") }),
        name: string({ validation: validation.create("required") }),
        fieldId: string({ validation: validation.create("required") }),
        label: i18nString({ context }),
        helpText: i18nString({ context }),
        placeholderText: i18nString({ context }),
        options: fields({
            list: true,
            instanceOf: withFields({
                label: i18nString({ context }),
                value: string({ value: "" })
            })()
        }),
        validation: fields({
            list: true,
            instanceOf: withFields({
                name: string({ validation: validation.create("required") }),
github webiny / webiny-js / packages / api-page-builder / src / plugins / models / pbCategory.model.js View on Github external
export default ({ createBase }) =>
    flow(
        withName("PbCategory"),
        withFields({
            name: string({ validation: validation.create("required") }),
            slug: string({ validation: validation.create("required") }),
            url: string({ validation: validation.create("required") }),
            layout: string()
        })
    )(createBase());
github webiny / webiny-js / packages / api-cookie-policy / src / cookiePolicySettings.model.js View on Github external
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()
                        })()
                    })
                })()
            })
        })
    )(createBase());
};
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-forms / src / plugins / models / Form / createFieldModel.js View on Github external
export default context =>
    withFields({
        _id: string({ validation: validation.create("required") }),
        type: string({ validation: validation.create("required") }),
        name: string({ validation: validation.create("required") }),
        fieldId: string({ validation: validation.create("required") }),
        label: i18nString({ context }),
        helpText: i18nString({ context }),
        placeholderText: i18nString({ context }),
        options: fields({
            list: true,
            instanceOf: withFields({
                label: i18nString({ context }),
                value: string({ value: "" })
            })()
        }),
        validation: fields({
            list: true,
            instanceOf: withFields({
                name: string({ validation: validation.create("required") }),
                message: i18nString({ context }),
                settings: object({ value: {} })
            })()
        }),
        settings: object({ value: {} })
    })();
github webiny / webiny-js / packages / api-page-builder / src / plugins / models / pbPageElement.model.js View on Github external
export default ({ createBase, context }) =>
    flow(
        withName("PbPageElement"),
        withFields({
            name: string({ validation: validation.create("required") }),
            category: string(),
            type: string({ validation: validation.create("required,in:element:block") }),
            content: content({ context }),
            preview: context.commodo.fields.id()
        })
    )(createBase({ maxPerPage: 1000 }));
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) {