blob: 786e2e3554e437d823b3387813e32c6e511acc92 [file] [log] [blame]
Serge Bazanskicc25bdf2018-10-25 14:02:58 +02001// 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
15package validate
16
17import (
18 "github.com/go-openapi/errors"
19)
20
21// Error messages related to schema validation and returned as results.
22const (
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 // InvalidSchemaProvidedError indicates that the schema provided to validate a value cannot be properly compiled
32 InvalidSchemaProvidedError = "Invalid schema provided to SchemaValidator: %v"
33
34 // InvalidTypeConversionError indicates that a numerical conversion for the given type could not be carried on
35 InvalidTypeConversionError = "invalid type conversion in %s: %v "
36
37 // MustValidateAtLeastOneSchemaError indicates that in a AnyOf construct, none of the schema constraints specified were verified
38 MustValidateAtLeastOneSchemaError = "%q must validate at least one schema (anyOf)"
39
40 // MustValidateOnlyOneSchemaError indicates that in a OneOf construct, either none of the schema constraints specified were verified, or several were
41 MustValidateOnlyOneSchemaError = "%q must validate one and only one schema (oneOf). %s"
42
43 // MustValidateAllSchemasError indicates that in a AllOf construct, at least one of the schema constraints specified were not verified
44 //
45 // TODO: punctuation in message
46 MustValidateAllSchemasError = "%q must validate all the schemas (allOf)%s"
47
48 // MustNotValidateSchemaError indicates that in a Not construct, the schema constraint specified was verified
49 MustNotValidateSchemaError = "%q must not validate the schema (not)"
50)
51
52// Warning messages related to schema validation and returned as results
53const ()
54
55func invalidSchemaProvidedMsg(err error) errors.Error {
56 return errors.New(InternalErrorCode, InvalidSchemaProvidedError, err)
57}
58func invalidTypeConversionMsg(path string, err error) errors.Error {
59 return errors.New(errors.CompositeErrorCode, InvalidTypeConversionError, path, err)
60}
61func mustValidateOnlyOneSchemaMsg(path, additionalMsg string) errors.Error {
62 return errors.New(errors.CompositeErrorCode, MustValidateOnlyOneSchemaError, path, additionalMsg)
63}
64func mustValidateAtLeastOneSchemaMsg(path string) errors.Error {
65 return errors.New(errors.CompositeErrorCode, MustValidateAtLeastOneSchemaError, path)
66}
67func mustValidateAllSchemasMsg(path, additionalMsg string) errors.Error {
68 return errors.New(errors.CompositeErrorCode, MustValidateAllSchemasError, path, additionalMsg)
69}
70func mustNotValidatechemaMsg(path string) errors.Error {
71 return errors.New(errors.CompositeErrorCode, MustNotValidateSchemaError, path)
72}
73func hasADependencyMsg(path, depkey string) errors.Error {
74 return errors.New(errors.CompositeErrorCode, HasDependencyError, path, depkey)
75}
76func arrayDoesNotAllowAdditionalItemsMsg() errors.Error {
77 return errors.New(errors.CompositeErrorCode, ArrayDoesNotAllowAdditionalItemsError)
78}