Giter VIP home page Giter VIP logo

Comments (13)

Grokzen avatar Grokzen commented on July 21, 2024

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.

run2fail avatar run2fail commented on July 21, 2024

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.

Grokzen avatar Grokzen commented on July 21, 2024

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.

run2fail avatar run2fail commented on July 21, 2024

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.

Grokzen avatar Grokzen commented on July 21, 2024

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.

run2fail avatar run2fail commented on July 21, 2024

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.

Grokzen avatar Grokzen commented on July 21, 2024

Okey, i will keep digging

from pykwalify.

Grokzen avatar Grokzen commented on July 21, 2024

I have located the problem and working on a fix and a new release that will include it.

from pykwalify.

Grokzen avatar Grokzen commented on July 21, 2024

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.

run2fail avatar run2fail commented on July 21, 2024

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.

Grokzen avatar Grokzen commented on July 21, 2024

Ye it sounds like a good default value, i fix.

from pykwalify.

Grokzen avatar Grokzen commented on July 21, 2024

There pushed a commit that makes it default to "any"

from pykwalify.

Grokzen avatar Grokzen commented on July 21, 2024

@run2fail New release made so you should be able to use it for now :]

from pykwalify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.