Comments (13)
From what i see you are using the validation rules correct and it should fail yes. But what i am thinking is that you might be missing some value for the foo
key and that might cause some issues. I will run some tests myself with the data you provided and see if i can track down the error.
from pykwalify.
Thanks for your reply.
I just noticed that in 17s.yaml you specify regex;mi.+:
but according to your documentation it shoud be regex;(mi.+):
.
In rule.py line 358 you are stripping the first and last character from the regex:
regex_rule.init(v, "{}/mapping;regex/{}".format(path, regex[1:-1]))
I can't tell if this is a problem as I didn't have the time to study the whole code but maybe this helps you.
from pykwalify.
Hmm... It is wierd because from what i see it should fail on file 17s.yaml because if mi.+
becomes i+
by stripping the first and last character then it should fail when it validates against mic
, so i guess that is a bug in itself.
One easy thing i can do is to make better validation of the regex that it acctually starts with (
and ends with )
and throw error because the validation/rules is bad.
from pykwalify.
An additional check for the parentheses around the regex sounds great and would surely catch some errors but I also fear that the matching problem is somewhere "down the road"...
from pykwalify.
Okey i think i got what is wrong.
Firstly you are mixing up the versions and what code/doc should be looked at. Your links to doc and code in previous comments was for master
branch where stuff have happened sinc 14.08
release. The docs might be the same describing how regex:(pattern)
works but they are processed in the code differently.
What i found out when i looked at the 14.08
code was that the parsed regex that was extracted from the key do not filter out any ( and ) and by that uses the entire raw regex and it might cause some issues because ( ) is used in regex.
Besides that i think you should avoid using ( ) in the pattern part of regex directive and see if that helps any. If possible, could you clone out the latest code from master
branch and test your schema/data files there and see if there is any difference?
If i find anything myself in the code that needs updating i will push it and make a new release that you maybe could look into.
from pykwalify.
I checked out the master branch after removing all old versions of pykwalify. I checked with find
if there are any leftovers in /usr/
. Then I installed with make install
.
I tested both examples from the first post, with files named data.yaml
, schema.yaml
, data2.yaml
, and schema2.yaml
. These are the results:
data.yaml
,schema.yaml
:INFO - validation.valid
data2.yaml
,schema2.yaml
:INFO - validation.valid
and just for curiosity's sake, I also tested:
data.yaml
,schema2.yaml
:INFO - validation.valid
data2.yaml
,schema.yaml
:INFO - validation.valid
Can you confirm this? I hope my installation is not totalled borked.
By the way, the version that I originally downloaded as 14.08 via pip
from PyPi also containes the line (but as line 341):
regex_rule.init(v, "{}/mapping;regex/{}".format(path, regex[1:-1]))
Nevertheless, parenthesis inside the regex shouldn't be an issue as this just defines a group.
from pykwalify.
Okey, i will keep digging
from pykwalify.
I have located the problem and working on a fix and a new release that will include it.
from pykwalify.
f7af11e Shold fix the problem right now. I still have some changes i want to make before the regex is really good but this should fix the current issue you are seeing. I have seen some issues when making a map validation that if you mix regex and normal keys regex will break some.
I tested with your example and i now get a validation error as expected.
from pykwalify.
That sounds great and does indeed work as expected.
Just one remark: matching-rule: "any"
is required, otherwise the validation will still be false-positive. Would you mind making this an implcit default so that it does not have to be specified at all?
from pykwalify.
Ye it sounds like a good default value, i fix.
from pykwalify.
There pushed a commit that makes it default to "any"
from pykwalify.
@run2fail New release made so you should be able to use it for now :]
from pykwalify.
Related Issues (20)
- Union of schemas HOT 4
- rule.py is missing a comma in defined_keywords list
- Deprecation warning due to invalid escape sequences in Python 3.8 HOT 1
- Fails to regex match a mapping with integer keys HOT 1
- AttributeError: 'int' object has no attribute 'startswith'
- Support multiple data type HOT 1
- New release? Maintainers needed or? HOT 2
- Deprecation warning "the imp module is deprecated in favour of importlib" HOT 1
- pattern rule not working with all scalar types HOT 1
- <RuleError: error code 4
- Using fulmatch for regex matching. HOT 1
- Schema Validation Against Multiple Files HOT 1
- Outputting Scan Results in SARIF Format HOT 1
- How can I check key only? HOT 5
- anchors to inherit properties are falsely reported as Duplicate HOT 2
- ReadTheDocs does not seem to be updating
- Some error message for length violations are wrong
- issue while using "unique: true" for the sequence data type HOT 3
- Tests fail with ruamel.yaml 0.18.0
- Core Validation Fails - Multi Threading & Python 3.11 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pykwalify.