ValidatePRInfo validates the PR/MR info schema.
(data interface{}, version PRInfoVersion)
| 389 | |
| 390 | // ValidatePRInfo validates the PR/MR info schema. |
| 391 | func ValidatePRInfo(data interface{}, version PRInfoVersion) error { |
| 392 | prInfoOnce.Do(initPRInfoSchemas) |
| 393 | |
| 394 | if version == "" { |
| 395 | version = PRInfoVersion1_3 |
| 396 | } |
| 397 | |
| 398 | schema, ok := compiledPRInfoSchemas[version] |
| 399 | if !ok { |
| 400 | return errors.New("invalid PR info schema version") |
| 401 | } |
| 402 | |
| 403 | if err := schema.Validate(data); err != nil { |
| 404 | var invalidJSONTypeError jsonschema.InvalidJSONTypeError |
| 405 | if errors.As(err, &invalidJSONTypeError) { |
| 406 | return ErrInvalidJSONPayload |
| 407 | } |
| 408 | return err |
| 409 | } |
| 410 | |
| 411 | return nil |
| 412 | } |
| 413 | |
| 414 | // ValidateAIAgentConfig validates the AI agent config schema. |
| 415 | func ValidateAIAgentConfig(data any, version AIAgentConfigVersion) error { |