How to use the strapi-helper-plugin.translatedErrors.min function in strapi-helper-plugin

To help you get started, we’ve selected a few strapi-helper-plugin 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 strapi / strapi / packages / strapi-plugin-content-manager / admin / src / containers / EditViewDataManagerProvider / utils / schema.js View on Github external
yup.addMethod(yup.array, 'notEmptyMin', function(min) {
  return this.test('notEmptyMin', errorsTrads.min, value => {
    if (isEmpty(value)) {
      return true;
    }
    return value.length >= min;
  });
});
github strapi / strapi / packages / strapi-plugin-content-manager / admin / src / containers / EditViewDataManagerProvider / utils / schema.js View on Github external
if (attribute.type === 'dynamiczone') {
        let dynamicZoneSchema = yup.array().of(
          yup.lazy(({ __component }) => {
            return createYupSchema(components[__component], { components });
          })
        );

        const { max, min } = attribute;

        if (attribute.required) {
          dynamicZoneSchema = dynamicZoneSchema.required();

          if (min) {
            dynamicZoneSchema = dynamicZoneSchema
              .min(min, errorsTrads.min)
              .required(errorsTrads.required);
          }
        } else {
          if (min) {
            dynamicZoneSchema = dynamicZoneSchema.notEmptyMin(min);
          }
        }

        if (max) {
          dynamicZoneSchema = dynamicZoneSchema.max(max, errorsTrads.max);
        }

        acc[current] = dynamicZoneSchema;
      }

      return acc;
github strapi / strapi / packages / strapi-plugin-content-manager / admin / src / containers / EditView / utils / schema.js View on Github external
((!isBoolean(validationValue) &&
        Number.isInteger(Math.floor(validationValue))) ||
        validationValue === 0)
    ) {
      switch (validation) {
        case 'required':
          schema = schema.required(errorsTrads.required);
          break;
        case 'max':
          schema = schema.max(validationValue, errorsTrads.max);
          break;
        case 'maxLength':
          schema = schema.max(validationValue, errorsTrads.maxLength);
          break;
        case 'min':
          schema = schema.min(validationValue, errorsTrads.min);
          break;
        case 'minLength':
          schema = schema.min(validationValue, errorsTrads.minLength);
          break;
        case 'regex':
          schema = schema.matches(validationValue, errorsTrads.regex);
          break;
        case 'lowercase':
          if (['text', 'textarea', 'email', 'string'].includes(type)) {
            schema = schema.strict().lowercase();
          }
          break;
        case 'uppercase':
          if (['text', 'textarea', 'email', 'string'].includes(type)) {
            schema = schema.strict().uppercase();
          }
github strapi / strapi / packages / strapi-plugin-content-type-builder / admin / src / containers / FormModal / utils / forms.js View on Github external
});
        case 'enumeration':
          return yup.object().shape({
            name: yup
              .string()
              .unique(errorsTrads.unique, alreadyTakenAttributes)
              .matches(ENUM_REGEX, errorsTrads.regex)
              .required(errorsTrads.required),
            type: yup.string().required(errorsTrads.required),
            default: yup.string().nullable(),
            unique: yup.boolean().nullable(),
            required: yup.boolean(),
            enum: yup
              .array()
              .of(yup.string())
              .min(1, errorsTrads.min)
              .hasNotEmptyValues(
                'Empty strings are not allowed',
                dataToValidate.enum
              ),
            enumName: yup.string().nullable(),
          });
        case 'number':
        case 'integer':
        case 'biginteger':
        case 'float':
        case 'decimal': {
          if (dataToValidate.type === 'biginteger') {
            return yup.object().shape({
              ...commonShape,
              default: yup
                .string()