diff --git a/libs/jsonschema/instance.go b/libs/jsonschema/instance.go index 5ae554e7b..6acd139b5 100644 --- a/libs/jsonschema/instance.go +++ b/libs/jsonschema/instance.go @@ -133,13 +133,16 @@ func (s *Schema) validatePattern(instance map[string]any) error { } func (s *Schema) validateConst(instance map[string]any) error { - for name, property := range s.Properties { - if property.Const == nil { + for k, v := range instance { + fieldInfo, ok := s.Properties[k] + if !ok { continue } - v, ok := instance[name] - if ok && v != property.Const { - return fmt.Errorf("expected value of property %s to be %v. Found: %v", name, property.Const, v) + if fieldInfo.Const == nil { + continue + } + if v != fieldInfo.Const { + return fmt.Errorf("expected value of property %s to be %v. Found: %v", k, fieldInfo.Const, v) } } return nil diff --git a/libs/template/config.go b/libs/template/config.go index fff26453e..f23fef605 100644 --- a/libs/template/config.go +++ b/libs/template/config.go @@ -125,6 +125,12 @@ func (c *config) skipPrompt(p jsonschema.Property, r *renderer) (bool, error) { return false, nil } + var keys []string + for k := range p.Schema.SkipPromptIf.Properties { + keys = append(keys, k) + } + p.Schema.SkipPromptIf.Required = append(keys, p.Schema.SkipPromptIf.Required...) + validationErr := p.Schema.SkipPromptIf.ValidateInstance(c.values) if validationErr != nil { return false, nil