( jsonPaths []JSONPathInfo, schemaJSON, filePath string, ctx frontmatterContextData, )
| 403 | } |
| 404 | |
| 405 | func formatJSONSchemaValidationWithLocation( |
| 406 | jsonPaths []JSONPathInfo, |
| 407 | schemaJSON, filePath string, |
| 408 | ctx frontmatterContextData, |
| 409 | ) error { |
| 410 | if len(jsonPaths) == 0 || ctx.frontmatterContent == "" { |
| 411 | return nil |
| 412 | } |
| 413 | |
| 414 | detailLines := make([]string, 0, len(jsonPaths)) |
| 415 | for _, pathInfo := range jsonPaths { |
| 416 | detailLines = append(detailLines, formatSchemaFailureDetail(pathInfo, schemaJSON, ctx.frontmatterContent, ctx.frontmatterStart)) |
| 417 | } |
| 418 | |
| 419 | location := LocateJSONPathForPathInfo(ctx.frontmatterContent, jsonPaths[0]) |
| 420 | if !location.Found { |
| 421 | return nil |
| 422 | } |
| 423 | adjustedLine := location.Line + ctx.frontmatterStart - 1 |
| 424 | contextLines := buildAdjustedContextLines(ctx, adjustedLine) |
| 425 | message := formatSchemaDetailMessage(detailLines) |
| 426 | return formatCompilerErrorWithLocation(filePath, adjustedLine, location.Column, message, contextLines) |
| 427 | } |
| 428 | |
| 429 | func buildAdjustedContextLines(ctx frontmatterContextData, adjustedLine int) []string { |
| 430 | if len(ctx.allLines) == 0 { |
no test coverage detected