...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package validate
16
17 import (
18 "github.com/go-openapi/errors"
19 )
20
21
22 const (
23
24
25
26 ArrayDoesNotAllowAdditionalItemsError = "array doesn't allow for additional items"
27
28
29 HasDependencyError = "%q has a dependency on %s"
30
31
32 InvalidSchemaProvidedError = "Invalid schema provided to SchemaValidator: %v"
33
34
35 InvalidTypeConversionError = "invalid type conversion in %s: %v "
36
37
38 MustValidateAtLeastOneSchemaError = "%q must validate at least one schema (anyOf)"
39
40
41 MustValidateOnlyOneSchemaError = "%q must validate one and only one schema (oneOf). %s"
42
43
44
45
46 MustValidateAllSchemasError = "%q must validate all the schemas (allOf)%s"
47
48
49 MustNotValidateSchemaError = "%q must not validate the schema (not)"
50 )
51
52
53 const ()
54
55 func invalidSchemaProvidedMsg(err error) errors.Error {
56 return errors.New(InternalErrorCode, InvalidSchemaProvidedError, err)
57 }
58 func invalidTypeConversionMsg(path string, err error) errors.Error {
59 return errors.New(errors.CompositeErrorCode, InvalidTypeConversionError, path, err)
60 }
61 func mustValidateOnlyOneSchemaMsg(path, additionalMsg string) errors.Error {
62 return errors.New(errors.CompositeErrorCode, MustValidateOnlyOneSchemaError, path, additionalMsg)
63 }
64 func mustValidateAtLeastOneSchemaMsg(path string) errors.Error {
65 return errors.New(errors.CompositeErrorCode, MustValidateAtLeastOneSchemaError, path)
66 }
67 func mustValidateAllSchemasMsg(path, additionalMsg string) errors.Error {
68 return errors.New(errors.CompositeErrorCode, MustValidateAllSchemasError, path, additionalMsg)
69 }
70 func mustNotValidatechemaMsg(path string) errors.Error {
71 return errors.New(errors.CompositeErrorCode, MustNotValidateSchemaError, path)
72 }
73 func hasADependencyMsg(path, depkey string) errors.Error {
74 return errors.New(errors.CompositeErrorCode, HasDependencyError, path, depkey)
75 }
76 func arrayDoesNotAllowAdditionalItemsMsg() errors.Error {
77 return errors.New(errors.CompositeErrorCode, ArrayDoesNotAllowAdditionalItemsError)
78 }
79
View as plain text