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

The purpose of minLengthOneError #49

Open
vbilenko-te opened this issue Oct 27, 2023 · 2 comments
Open

The purpose of minLengthOneError #49

vbilenko-te opened this issue Oct 27, 2023 · 2 comments

Comments

@vbilenko-te
Copy link

Hi,
First of all want to say thank you for developing such useful lib for JSON Schema.
Have one question: what the purpose of minLengthOneError?
According to official JSON Schema specification there is no such validator.
Wouldn't say it cause a problem but still have to handle it separately.

@sagold
Copy link
Owner

sagold commented Oct 27, 2023

Hi,

thank you for your feedback!

The minLengthOneError is thrown for validation errors of minLength: 1. This can be used to test for required input of string values, since there is no json-schema equivalent. The specific error simplifies custom error messages for this case. E.g. you can state that an input/value is expected, instead of telling that the input requires a minimum length of 1.

This behaviour can also be changed.

Are you having issues, because you checked for minError?

@vbilenko-te
Copy link
Author

vbilenko-te commented Oct 27, 2023

Thanks for the answer.
Not a technical problem.
Abstractly speaking there are two teams who using different libraries and it is hard to explain why it is only me who has a custom schema error which is not documented in official JSON Schema specification.
For now I manage it as a regular minLength to follow official spec.
So, just want to says it's would be nice to maintain compatibility with official public specifications to ensure consistency and compatibility across different systems.
On my subjective opinion maybe it is better to throw both minLength and minLengthOne errors to keep compatible with spec and also provide additional custom error at the same time?

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

No branches or pull requests

2 participants