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

More accurate validation messages on constraints #148

Merged
merged 1 commit into from
Mar 10, 2020

Conversation

mattfarina
Copy link
Member

Previously the validation messages were simply tied to the operator.
There were cases where the message lost its meaning. For example,
a constraing of ^1.12.7 with a version to check of 1.6.6 would have
said the major version did not match. This is not true.

The errors were reworked to be part of the functions performing the
check. This would allow some errors returned to be different from
others. For example, in the case listed here it could not the one
is less than the other. The varying cases is important for ^ as
it has special rules for cases when the major is 0 or the major
and minor are 0. Validation messages appropriate for each of those
cases can be returned.

Note, in v4 of this library there can be one function for checking
and validation as the internals enable that now. The Check function
on constraints can return errors with it and the Validation method
can be removed. That wasn't put into place now as it would be API
breaking under semver rules.

Closes #145

Previously the validation messages were simply tied to the operator.
There were cases where the message lost its meaning. For example,
a constraing of ^1.12.7 with a version to check of 1.6.6 would have
said the major version did not match. This is not true.

The errors were reworked to be part of the functions performing the
check. This would allow some errors returned to be different from
others. For example, in the case listed here it could not the one
is less than the other. The varying cases is important for ^ as
it has special rules for cases when the major is 0 or the major
and minor are 0. Validation messages appropriate for each of those
cases can be returned.

Note, in v4 of this library there can be one function for checking
and validation as the internals enable that now. The Check function
on constraints can return errors with it and the Validation method
can be removed. That wasn't put into place now as it would be API
breaking under semver rules.

Closes Masterminds#145
@mattfarina
Copy link
Member Author

@AlketaR care to take a look at this?

Copy link
Member

@technosophos technosophos left a comment

Choose a reason for hiding this comment

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

👍 👍

@mattfarina mattfarina merged commit 5bc507e into Masterminds:master Mar 10, 2020
@mattfarina mattfarina deleted the fix-145 branch March 10, 2020 13:19
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.

no valid error messages from Validate() when constraints are build with caret or tilde
2 participants