-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there any possibility to match map key to str or seq? #97
Comments
@AKorezin Unless you can post the schema that you are working on, I will not be able to help you with fixing this problem. I think i know what your problem is, but i need to see what you have produced yourself. |
Schema type: seq
sequence:
- type: map
mapping:
name:
type: str
ip:
type: seq
sequence:
- type: str validates - name: Server 1
ip:
- 10.0.0.1
- name: Server 2
ip:
- 10.0.0.2
- 10.0.0.3 Schema type: seq
sequence:
- type: map
mapping:
name:
type: str
ip:
type: str validates - name: Server 1
ip: 10.0.0.1
- name: Server 2
ip: 10.0.0.2 How to validate this? - name: Server 1
ip: 10.0.0.1
- name: Server 2
ip:
- 10.0.0.2
- 10.0.0.3 |
Okey i think i see what the problem is. The feature you are talking about But, i tried to hack around this problem, but i was not able to solve it with the One problem that i am having is how to extend the schema definition to include multiple paths in a good way. There is a suggestion on implementing a kind of directive It might sound wierd but you maybe would have better luck by trying another validation framework, maybe you will have more luck with jsonschema for example. |
I was about to report a new issue but found this first. I did the "hack" that you did and here are the results: matching-rule: 'any'
map:
regex;(layout):
type: str
enum: ['nn', 'nt', 'tn', 'tt']
regex;(layout):
seq:
- type: str
enum: ['nn', 'nt', 'tn', 'tt'] data passing validation --> layout:
- tt
- tn data not passing validation --> layout: nt When the validation fails I get this message:
If I swap the regexs in the schema I get an error on the first data while the second passes
I also tested two orderings of the same regex value with a string type and different allowed enums and I got an error with one of the orderings. I agree that matching-rule is not the same as any_of (which is included in the json-schema which coincidentally I wrote a validator for in C++ but am trying to use pykwalify since I moved to python). I want to encourage you to think about the simple boolean operators, one_of, any_of, not, etc from json-schema, I found that they were not too hard to implement, just a loop at that node with different control flow based on the rule and using sub-validators to handle/ignore errors properly. Because this feature does not exist in pykwalify, I will have to write a bunch of special case validation code in my application. |
@AKorezin this does what you want: matching: "any"
sequence:
- type: map
mapping:
name:
type: str
ip:
type: seq
sequence:
- type: str
- type: map
mapping:
name:
type: str
ip:
type: str @Grokzen sequences have any_of already implemented, it shouldn't be too hard to extend this to a any_of primitive like this: map:
layout:
any_of:
- seq:
- type: str
enum: ['nn', 'nt', 'tn', 'tt']
- type: str
enum: ['nn', 'nt', 'tn', 'tt'] |
Having more direct support for this config:
input_values: JustOneString
---
config:
input_values:
- oneString
- andAnotherOne This idiom seems very convenient, but because |
I know i like the idea of
|
Is there a good jsonschema python implementation?
…On Thu, Jun 7, 2018 at 10:44 AM, Grokzen ***@***.***> wrote:
I know i like the idea of any_of to be supported on more types. The main
issue is that
1. It is not really part of the original kwalify spec so i "should"
not implemented it, even if i have implemented other fields so this is
kinda mute.
2. One of the more major things i do not like with the progression of
features that both i and other have added is that this syntax is moving
closer and closer to what jsonschema already provides and it only feels
like a reimplmentation of that syntax/specification but not doing it as
well as them.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#97 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AOrPzjGddSU4Jiwiel9oAgu2KQQALni_ks5t6TxbgaJpZM4NProD>
.
|
Define "good"? :] But this one by a quick googling https://pypi.org/project/jsonschema/ should work probably. Note that the main idea of pykwalify was to provide a moving forward solution to people that was embeded with kwalify from the days of old. It was not a solution/spec to be something better then the other leading validation frameworks, specially jsonschema. |
thanks for the pointer, I was pursuing pykwalify because I thought it was
evolving to be more like json schema and more fully featured. If I missed
it sorry but "main idea of pykwalify" should be clearly stated in the main
description, to prevent future users from unmet expectations
…On Thu, Jun 7, 2018 at 10:49 AM, Grokzen ***@***.***> wrote:
Define "good"? :]
But this one by a quick googling https://pypi.org/project/jsonschema/
should work probably.
Note that the main idea of pykwalify was to provide a moving forward
solution to people that was embeded with kwalify from the days of old. It
was not a solution/spec to be something better then the other leading
validation frameworks, specially jsonschema.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#97 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AOrPznt9cL9QEFV2ErB7QXAO00sH-FKrks5t6T2IgaJpZM4NProD>
.
|
@StephenEhmann Ye i know, i probably will update it to make it more clear what the purpose is and what to expect from me regarding this repo. |
Hello.
I've tried to create a schema to match this:
But I don't really understand how to do that, because
matching
is only available isseq
block.Is my problem related to the issue #45?
The text was updated successfully, but these errors were encountered: