Add schema selection values and ownership
This commit is contained in:
@@ -22,8 +22,26 @@ func ValidateOutputContract(contract OutputContract) error {
|
||||
return fmt.Errorf("invalid validation mode: %q", contract.ValidationMode)
|
||||
}
|
||||
|
||||
if contract.ValidationMode == ValidationJSONSchema && strings.TrimSpace(contract.SchemaPath) == "" {
|
||||
return errors.New("schema_path is required when validation_mode is json_schema")
|
||||
if contract.ValidationMode == ValidationJSONSchema {
|
||||
count := 0
|
||||
if contract.Schema != nil {
|
||||
count++
|
||||
}
|
||||
if contract.SchemaFile != nil {
|
||||
if strings.TrimSpace(*contract.SchemaFile) == "" {
|
||||
return errors.New("schema_file must not be blank")
|
||||
}
|
||||
count++
|
||||
}
|
||||
if contract.SchemaPath != "" {
|
||||
if strings.TrimSpace(contract.SchemaPath) == "" {
|
||||
return errors.New("schema_path must not be blank")
|
||||
}
|
||||
count++
|
||||
}
|
||||
if count != 1 {
|
||||
return errors.New("exactly one of schema, schema_file, or schema_path is required when validation_mode is json_schema")
|
||||
}
|
||||
}
|
||||
if contract.RepairAttempts < 0 {
|
||||
return errors.New("repair_attempts must be greater than or equal to 0")
|
||||
|
||||
Reference in New Issue
Block a user