Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ajv resolver to work with unlimited layers of nesting #412

Merged
merged 1 commit into from Jun 10, 2022

Conversation

NoRKin
Copy link
Contributor

@NoRKin NoRKin commented Jun 10, 2022

The current implementation of ajv resolver didn't support well more than 2 layers of nesting. The error keys wouldn't match the shape of the data. See below data/category.

The below schema results in:

{
  type: 'object', 
  properties: {
    row: {
      type: 'object',
      properties: {
	name: {
	  type: 'string',
	  minLength: 10,
	  errorMessage: { minLength: 'Username should be at least 10 characters' },
	},
	data: {
	  type: 'object',
	  properties: {
	    category: {
	      type: 'string',
	      minLength: 1,
	      errorMessage: { minLength: 'Category is required' },
	    }
	  },
	  required: ['category'],
	  additionalProperties: true,
	}
      },
      required: ['name', 'data'],
      additionalProperties: true,
    },
  },
  required: ['row'],
  additionalProperties: false,
};

Screen Shot 2022-06-10 at 1 18 20 pm

The fix is to essentially replace all occurrences of / instead of only the first one.

Copy link
Member

@bluebill1049 bluebill1049 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR 🙏

@jorisre jorisre merged commit 692fe65 into react-hook-form:master Jun 10, 2022
@github-actions
Copy link
Contributor

🎉 This PR is included in version 2.9.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants