MCPcopy Create free account
hub / github.com/vale-cli/vale / validateDefinition

Function validateDefinition

internal/check/definition.go:237–275  ·  view source on GitHub ↗
(generic map[string]interface{}, path string)

Source from the content-addressed store, hash-verified

235}
236
237func validateDefinition(generic map[string]interface{}, path string) error {
238 if point, ok := generic["extends"]; !ok || point == nil {
239 return core.NewE201FromPosition(
240 "Missing the required 'extends' key.",
241 path,
242 1)
243 } else if !core.StringInSlice(point.(string), extensionPoints) {
244 key, _ := point.(string)
245 return core.NewE201FromTarget(
246 fmt.Sprintf("'extends' key must be one of %v.", extensionPoints),
247 key,
248 path)
249 }
250
251 if _, ok := generic["message"]; !ok {
252 return core.NewE201FromPosition(
253 "Missing the required 'message' key.",
254 path,
255 1)
256 }
257
258 if level, ok := generic["level"]; ok {
259 if level == nil || !core.StringInSlice(level.(string), core.AlertLevels) {
260 return core.NewE201FromTarget(
261 fmt.Sprintf("'level' must be one of %v", core.AlertLevels),
262 "level",
263 path)
264 }
265 }
266
267 if generic["code"] != nil && generic["code"].(bool) {
268 return core.NewE201FromTarget(
269 "`code` is deprecated; please use `scope: raw` instead.",
270 "code",
271 path)
272 }
273
274 return nil
275}
276
277func readStructureError(err error, path string) error {
278 r1 := regexp.MustCompile(`\* '(.+)' (.+)`)

Callers 1

parseFunction · 0.85

Calls 3

NewE201FromPositionFunction · 0.92
StringInSliceFunction · 0.92
NewE201FromTargetFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…