You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I apologize if I missed this in the docs for kwalify or pykwalify, or if this was already addressed in an earlier issue (I have searched but cannot find anything). I'd like to validate a schema that uses custom tags. Between the pyyaml and pykwalify documentation this is the best I was able to come up with. But its obviously not right. Example:
dump: !MyTag {name: aname, parameter: 2}
Traceback (most recent call last):
File "example.py", line 34, in <module>
c.validate(raise_exception=True)
File "/usr/local/lib/python2.7/dist-packages/pykwalify/core.py", line 155, in validate
self._start_validate(self.source)
File "/usr/local/lib/python2.7/dist-packages/pykwalify/core.py", line 197, in _start_validate
root_rule = Rule(schema=self.schema)
File "/usr/local/lib/python2.7/dist-packages/pykwalify/rule.py", line 66, in __init__
self.init(schema, "")
File "/usr/local/lib/python2.7/dist-packages/pykwalify/rule.py", line 399, in init
path=path,
pykwalify.errors.RuleError: <RuleError: error code 4: Key 'type' in schema rule is not a string type (found MyTag): Path: '/'>
The text was updated successfully, but these errors were encountered:
@yamokosk Can you supply a working script that correctly loads the custom tag you made and where it would build up a data object that acctually work on the python side so i can then implement this in the code base?
@yamokosk So i was thinking, in theory you should be able to add in any tag by modifying the following variable https://github.com/Grokzen/pykwalify/blob/master/pykwalify/compat.py#L10 that is the ruamel.yaml object and you should be able to add in any tags you want same way as here https://github.com/Grokzen/pykwalify/blob/master/pykwalify/core.py#L68 and if you do this before you construct your Core object it should be added to your parser when loading your schema/data files. It might be some issues with the ordering of imports and adding the tag, but it should be possible to make that work i guess.
I apologize if I missed this in the docs for kwalify or pykwalify, or if this was already addressed in an earlier issue (I have searched but cannot find anything). I'd like to validate a schema that uses custom tags. Between the pyyaml and pykwalify documentation this is the best I was able to come up with. But its obviously not right. Example:
Output:
The text was updated successfully, but these errors were encountered: