(r io.Reader, loader gojsonschema.JSONLoader)
| 21 | } |
| 22 | |
| 23 | func lint(r io.Reader, loader gojsonschema.JSONLoader) error { |
| 24 | data, err := io.ReadAll(r) |
| 25 | if err != nil { |
| 26 | return err |
| 27 | } |
| 28 | var m any |
| 29 | if err := Unmarshal(data, &m); err != nil { |
| 30 | return err |
| 31 | } |
| 32 | sourceLoader := gojsonschema.NewGoLoader(m) |
| 33 | result, err := gojsonschema.Validate(loader, sourceLoader) |
| 34 | if err != nil { |
| 35 | return err |
| 36 | } |
| 37 | if len(result.Errors()) > 0 { |
| 38 | return ResultErrors(result.Errors()) |
| 39 | } |
| 40 | return nil |
| 41 | } |
| 42 | |
| 43 | // ResultErrors is a slice of gojsonschema.ResultError that implements error |
| 44 | type ResultErrors []gojsonschema.ResultError |
no test coverage detected