Handling multiple 'Match' rules picks last rule
See original GitHub issueI have a scenario where a certain value needs to match 2 separate regular expressions, and emit a different error message for each of them.
Example:
RuleFor(c => c.MobilePhoneNumber)
.NotEmpty()
.Length(10)
.Matches(@"^3").WithMessage("'{PropertyName}' should start with '3'.")
.Matches(@"^\d*$").WithMessage("'{PropertyName}' should only contain digits.");
However, when the swagger UI is rendered, I’m only getting the last regular expression
mobilePhoneNumber*
| stringmaxLength: 10
| minLength: 10
| pattern: ^\d*$
Is there something that could be done from the library side to properly show both rules in this particular case, so that the caller knows it needs to match more than one expression for the value to be valid?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Is this a viable approach to resolving multiple matches in ...
I am unsure of the best way to handle when multiple rules are matched. The existing lexers I've looked at handle this by...
Read more >Cisco ISE - What does "Multiple Matched Rule Applies" ...
This means that ISE just doesnt stop if you meet the first rule condition it keeps processing till you match all the rules...one...
Read more >Implementing multiple match rules in IDQ
I have to implement multiple match rules in IDQ in the following way: First Name AND Last Name AND Gender - All Exact....
Read more >Rule-based matching · spaCy Usage Documentation
spaCy features a rule-matching engine, the Matcher , that operates over tokens, similar to regular expressions. The rules can refer to token annotations ......
Read more >Selection rules and actions
You can explicitly select on multiple tables and schemas by specifying multiple selection rules.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Some investigations:
Using https://json-schema-validator.herokuapp.com/index.jsp
Schema:
TestCases:
Sample with two failed patterns
Result: Schema with two patterns works as expected!
I started to use allOf in new version and all patterns are in schema. But Swagger UI doesnot recognizes two patterns and shows only last!!!
Try this sample in https://editor.swagger.io/
Simple example:
Example with refs
Result: