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

Improves the way the validator displays matches with many possible values #355

Merged
merged 1 commit into from Apr 17, 2023

Conversation

rpaul-stripe
Copy link
Contributor

When a matches rule has a large number of possible matches (common when validating to make sure that links point to a valid route or that images point to a file that exists) the error message can be extremely verbose. This PR makes it so that when the number of possible values exceeds eight, the validator only lists the first eight explicitly and then indicates how many more potential values are available. This ensures that users don't get giant error messages with hundreds of possible values.

The new error message looks like this:

Attribute 'jawn' must match one of ["a","b","c","d","e","f","g","h", ... 4 more]. Got 'cat' instead.

This approach loosely imitates the way that the node.js repl displays long arrays that are printed with console.log.

@rpaul-stripe rpaul-stripe merged commit bfec21c into main Apr 17, 2023
2 checks passed
@rpaul-stripe rpaul-stripe deleted the trim-matches branch April 17, 2023 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants