-
Notifications
You must be signed in to change notification settings - Fork 114
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
Support query on dict/object values (breaking change!) #151
Conversation
schema/dict.go
Outdated
|
||
// ValuesValidator is deprecated, use Values instead to specify a Field. If | ||
// used, Values will be set to a required, non-filterable filed on Compile. | ||
// ValuesValidator FieldValidator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have an optino to add backwards compatibility by keeping the ValuesValidator field until we start on #77, if there is interest for it. It would add some complexity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I.e. I can either comment in or remove this code.
schema/dict.go
Outdated
Required: true, | ||
Validator: val, | ||
} | ||
}*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code would also either be commented in or removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this change require change in the documentation as well. There is almost no doc on schema.Dict
Good point @Dragomir-Ivanov. There looks to be no documentation in the README that needs updating, but the doc-comment should most sertanly be updated:
That seems pretty wrong 😆 |
df1dd03
to
bdb04ff
Compare
@rs / @Dragomir-Ivanov PR updated with documentation changes, including a new list of breaking changes. Sorry about the delay, it's been busy. |
@rs, would you prefer |
schema/dict.go
Outdated
if _, err := v.KeysValidator.Validate(name); err != nil { | ||
return nil | ||
} | ||
// TODO: As part of issue #77, replace Dict.ValuesValidator with a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO is out of date (already done)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
schema/field.go
Outdated
// present in the schema. | ||
// | ||
// You may reference sub field using dotted notation field.subfield. | ||
GetField(name string) *Field |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QueryField
could be a better name. At least when it comes to e.g. Array
and AnyOf
, we are interested in a Field that can be used to validate query values, not necessarily a field that can validate values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requires some rewrite of the whole logic to support better array querying, so we could wait with the rename this until we do the array part, if we need to slightly redo the logic anyway...
This commit adds support for looking up field definitions inside schema.Dict and schema.Object instances. To achieve this, Dict.ValuesValidator has been deprecated in favour of a new Dict.Values property that holds a full schema.Field. As a result, it should be possible to filter on schema.Dict and schema.Object sub-fields. PS! This commit does not add support for filtering on fields inside schema.Array, schema.AnyOf or schema.AllOf; this will come later.
Starting on #139, case 2.
@rs, some feedback on putting
Values Field
overValuesValidator FieldValidator
insideschema.Dict
. The idea would be to to do the same forschema.Array
in a later PR. This also allows description fields to be set byjsonschema
, as well as setting aFilterable
value, and would become very consistent once we start on #77.In addition
schema.AllOf
andschema.AnyOf
should ideally get a GetFields implementation, although this is a harder problem as they would need to return multiple fields.So far I have tested filtering to work with some simple manual test code:
This commit adds support for looking up field definitions inside
schema.Dict and schema.Object instances. To achieve this,
Dict.ValuesValidator has been deprecated in favour of a new Dict.Values
property that holds a full schema.Field.
As a result, it should be possible to filter on schema.Dict and
schema.Object sub-fields.
PS! This commit does not add support for filtering on fields inside
schema.Array, schema.AnyOf or schema.AllOf; this will come later.