fetch a shared correlated object off the validation options if it exists
c
This commit is contained in:
parent
0a19b5ab6e
commit
dfeab6eca8
@ -60,8 +60,20 @@ func (r *RatchetingSchemaValidator) Validate(new interface{}, options ...Validat
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *RatchetingSchemaValidator) ValidateUpdate(new, old interface{}, options ...ValidationOption) *validate.Result {
|
func (r *RatchetingSchemaValidator) ValidateUpdate(new, old interface{}, options ...ValidationOption) *validate.Result {
|
||||||
|
opts := NewValidationOptions(options...)
|
||||||
|
|
||||||
|
if !opts.Ratcheting {
|
||||||
|
sv := validate.NewSchemaValidator(r.schema, r.root, r.path, r.knownFormats, r.options...)
|
||||||
|
return sv.Validate(new)
|
||||||
|
}
|
||||||
|
|
||||||
|
correlation := opts.CorrelatedObject
|
||||||
|
if correlation == nil {
|
||||||
|
correlation = common.NewCorrelatedObject(new, old, &celopenapi.Schema{Schema: r.schema})
|
||||||
|
}
|
||||||
|
|
||||||
return newRatchetingValueValidator(
|
return newRatchetingValueValidator(
|
||||||
common.NewCorrelatedObject(new, old, &celopenapi.Schema{Schema: r.schemaArgs.schema}),
|
correlation,
|
||||||
r.schemaArgs,
|
r.schemaArgs,
|
||||||
).Validate(new)
|
).Validate(new)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user