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
and look at the pattern constraints being applied via the public Go API. Note that some may overlap, for example foo: "x/one": {} would unify with #SchemaAnyString & #SchemaX.
Also note that, per the spec, default constraints like foo: {...string} could also apply, but are not currently implemented.
One idea could be:
type PatternConstraint struct {
Pattern Value
Constraint Value
}
func (Value) Patterns() ([]PatternConstraint, error)
Marcel also briefly mentioned in a recent exchange that he had been toying with the idea of adapting the existing struct field iterator API (https://pkg.go.dev/cuelang.org/go/cue#Value.Fields) to support pattern constraints as well. For that to work, we might need two new APIs to enable iterating over pattern constraints, and then seeing their pattern values, given that Iterator.Selector is not enough:
func Patterns(include bool) Option
func (*Iterator) Pattern() Value
The text was updated successfully, but these errors were encountered:
I should also note that @cuematthew mentioned that trim needed this. He ended up using the internal APIs because the public APIs were missing features like this one.
Given a CUE value such as:
one can grab the
cue.Value
forfoo
and doval.LookupPath(cue.MakePath(cue.AnyString))
and obtain the reference value for#Entry
.However, given:
it is currently not possible to do the same; a lookup of "any string" returns an error because any string does not match the constraint.
In the more general case, it's impossible to inspect a CUE value such as
and look at the pattern constraints being applied via the public Go API. Note that some may overlap, for example
foo: "x/one": {}
would unify with#SchemaAnyString & #SchemaX
.Also note that, per the spec, default constraints like
foo: {...string}
could also apply, but are not currently implemented.One idea could be:
Marcel also briefly mentioned in a recent exchange that he had been toying with the idea of adapting the existing struct field iterator API (https://pkg.go.dev/cuelang.org/go/cue#Value.Fields) to support pattern constraints as well. For that to work, we might need two new APIs to enable iterating over pattern constraints, and then seeing their pattern values, given that
Iterator.Selector
is not enough:The text was updated successfully, but these errors were encountered: