export function assertValidProduct( product ) { const missingAttributes = difference( schema.required, Object.keys( product ) ); if ( ! isEmpty( missingAttributes ) ) { throw new Error( 'Missing required attributes for ProductValue: [' + missingAttributes.join( ', ' ) + ']' ); } }
validate(value) { if (this.options.required === true) { return this.isValue(value); } return true; }
/* eslint-disable indent */ /* eslint-disable prefer-arrow-callback */ yup.addMethod(yup.mixed, 'defined', function() { return this.test('defined', errorsTrads.required, value => value !== undefined); });
Object.keys(mainComponent.properties).reduce( (acc, current) => { if (privateAttributes.indexOf(current) === -1) { acc.properties[current] = mainComponent.properties[current]; } return acc; }, { required: mainComponent.required, properties: {} } )
schema(allCategories, initialData) { const allowedCategories = allCategories .filter(cat => cat !== initialData.name) .map(cat => toLower(cat)); return yup.object().shape({ name: yup .string() .matches(CATEGORY_NAME_REGEX, errorsTrads.regex) .unique(errorsTrads.unique, allowedCategories, toLower) .required(errorsTrads.required), }); }
yup .strapiID() .required() .test('no-admin-single-delete', 'You cannot delete the super admin role', async function(id) { const superAdminRole = await strapi.admin.services.role.getSuperAdmin(); return !superAdminRole || !stringEquals(id, superAdminRole.id) ? true : this.createError({ path: 'id', message: `You cannot delete the super admin role` }); })
Object.keys(definitions).reduce((program, opt) => { if (typeof definitions[opt] == 'object') { const additionalOptions = definitions[opt]; if (additionalOptions.required === true) { return program.option(`--${opt} <${opt}>`, additionalOptions.help, additionalOptions.action); } else { return program.option(`--${opt} [${opt}]`, additionalOptions.help, additionalOptions.action); } } return program.option(`--${opt} [${opt}]`); }, this);
const getTypeValidator = (attribute, { types, modelType, attributes }) => { return yup.object({ type: yup .string() .oneOf(types) .required(), configurable: yup.boolean().nullable(), private: yup.boolean().nullable(), ...getTypeShape(attribute, { modelType, attributes }), }); }
Joi.object().keys({ dimension: id, member: id, operator: Joi.valid(operators).required(), values: Joi.array().items(Joi.string().allow('', null), Joi.lazy(() => oneFilter)) }).xor('dimension', 'member')
const getTypeValidator = (attribute, { types, modelType, attributes }) => { return yup.object({ type: yup .string() .oneOf(types) .required(), configurable: yup.boolean().nullable(), private: yup.boolean().nullable(), ...getTypeShape(attribute, { modelType, attributes }), }); }
yup .strapiID() .required() .test('no-admin-single-delete', 'You cannot delete the super admin role', async function(id) { const superAdminRole = await strapi.admin.services.role.getSuperAdmin(); return !superAdminRole || !stringEquals(id, superAdminRole.id) ? true : this.createError({ path: 'id', message: `You cannot delete the super admin role` }); })
Object.keys(mainComponent.properties).reduce( (acc, current) => { if (privateAttributes.indexOf(current) === -1) { acc.properties[current] = mainComponent.properties[current]; } return acc; }, { required: mainComponent.required, properties: {} } )
/* eslint-disable indent */ /* eslint-disable prefer-arrow-callback */ yup.addMethod(yup.mixed, 'defined', function() { return this.test('defined', errorsTrads.required, value => value !== undefined); });