Add validation adding array nodes to Constraint#62
Open
ricardogama wants to merge 1 commit intoguillaumepotier:masterfrom
Open
Add validation adding array nodes to Constraint#62ricardogama wants to merge 1 commit intoguillaumepotier:masterfrom
ricardogama wants to merge 1 commit intoguillaumepotier:masterfrom
Conversation
49755a4 to
c8c54ac
Compare
c8c54ac to
36bcc79
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR improves validation of array nodes when instantiating or adding nodes to a
Constraintobject, since the following is currently allowed:Although an error is thrown when validating against the constraint, the error could be previously thrown when instantiating it and with a more adequate message.
With such motivation these changes lead to the following behaviour:
If an array node is provided with the first element's type not being
Assertan error is thrown with the following message:Should give at least one Assert on array nodesThis behaviour was already implemented but this message seems more adequate than the fallback message.
If any element's type of an array node is other than
Object,AssertorConstraintan error is thrown with the following message:Should give Assert or Constraint on array nodesIf there is more than one element with
ObjectorConstrainttype on an array node an error is thrown with the following message:Should not give more than one constraint on array nodesThe fallback error message for providing invalid nodes has been improved/fixed to:
Should give an Assert, an Asserts array or ConstraintThese changes do not break the current suite and tests were added for all cases, including a missing test for the fallback error message.