Debian Codegraph @

pkg/validation/validate/schema_messages.go

raw symbols SCIP
1 // Copyright 2015 go-swagger maintainers
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package validate
16
17 import (
18 "k8s.io/kube-openapi/pkg/validation/errors"
19 )
20
21 // Error messages related to schema validation and returned as results.
22 const (
23 // ArrayDoesNotAllowAdditionalItemsError when an additionalItems construct is not verified by the array values provided.
24 //
25 // TODO: should move to package go-openapi/errors
26 ArrayDoesNotAllowAdditionalItemsError = "array doesn't allow for additional items"
27
28 // HasDependencyError indicates that a dependencies construct was not verified
29 HasDependencyError = "%q has a dependency on %s"
30
31 // InvalidTypeConversionError indicates that a numerical conversion for the given type could not be carried on
32 InvalidTypeConversionError = "invalid type conversion in %s: %v "
33
34 // MustValidateAtLeastOneSchemaError indicates that in a AnyOf construct, none of the schema constraints specified were verified
35 MustValidateAtLeastOneSchemaError = "%q must validate at least one schema (anyOf)"
36
37 // MustValidateOnlyOneSchemaError indicates that in a OneOf construct, either none of the schema constraints specified were verified, or several were
38 MustValidateOnlyOneSchemaError = "%q must validate one and only one schema (oneOf). %s"
39
40 // MustValidateAllSchemasError indicates that in a AllOf construct, at least one of the schema constraints specified were not verified
41 //
42 // TODO: punctuation in message
43 MustValidateAllSchemasError = "%q must validate all the schemas (allOf)%s"
44
45 // MustNotValidateSchemaError indicates that in a Not construct, the schema constraint specified was verified
46 MustNotValidateSchemaError = "%q must not validate the schema (not)"
47 )
48
49 // Warning messages related to schema validation and returned as results
50 const ()
51
52 func invalidTypeConversionMsg(path string, err error) errors.Error {
53 return errors.New(errors.CompositeErrorCode, InvalidTypeConversionError, path, err)
54 }
55 func mustValidateOnlyOneSchemaMsg(path, additionalMsg string) errors.Error {
56 return errors.New(errors.CompositeErrorCode, MustValidateOnlyOneSchemaError, path, additionalMsg)
57 }
58 func mustValidateAtLeastOneSchemaMsg(path string) errors.Error {
59 return errors.New(errors.CompositeErrorCode, MustValidateAtLeastOneSchemaError, path)
60 }
61 func mustValidateAllSchemasMsg(path, additionalMsg string) errors.Error {
62 return errors.New(errors.CompositeErrorCode, MustValidateAllSchemasError, path, additionalMsg)
63 }
64 func mustNotValidatechemaMsg(path string) errors.Error {
65 return errors.New(errors.CompositeErrorCode, MustNotValidateSchemaError, path)
66 }
67 func hasADependencyMsg(path, depkey string) errors.Error {
68 return errors.New(errors.CompositeErrorCode, HasDependencyError, path, depkey)
69 }
70 func arrayDoesNotAllowAdditionalItemsMsg() errors.Error {
71 return errors.New(errors.CompositeErrorCode, ArrayDoesNotAllowAdditionalItemsError)
72 }