mirror of https://github.com/databricks/cli.git
Add required condition
This commit is contained in:
parent
77116cf1cf
commit
699f7dd527
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue