Skip to content

ValidateNested without decorator is not working #203

@zender

Description

@zender

Let's say we have the following validation schema:

// this will not work
export const taskValidationSchema: ValidationSchema = {
  name: 'TaskValidationSchema',
  properties: {
    'title': [
      {
        type: 'minLength',
        constraints: [3],
        groups: ['admin'],
      }
    ],
    'files': [
      {
        type: 'nestedValidation',
        each: true,
        groups: ['admin'],
      }
    ]
  }
};

Validator is not aware of which validation schema to use for the nested property.

Here is my solution:

export const taskValidationSchema: ValidationSchema = {
  name: 'TaskValidationSchema',
  properties: {
    'title': [
      {
        type: 'minLength',
        constraints: [3],
        groups: ['admin'],
      }
    ],
    'files': [
      {
        type: 'nestedValidation',
        options: {'validationSchema': 'TaskFileValidationSchema'},
        each: true,
        groups: ['admin'],
      }
    ]
  }
};

Would you accept PR?

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: blockedIssues being blocked by a different issue.type: fixIssues describing a broken feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions