summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authork8s-merge-robot <k8s.production.user@gmail.com>2015-12-19 03:57:53 -0800
committerk8s-merge-robot <k8s.production.user@gmail.com>2015-12-19 03:57:53 -0800
commit3a5e39abe9ab36b15565d30a4beebfb39d45f7c4 (patch)
tree9e4f4562f004b5e4c57946407d24b2443a0530d5
parentc415a6c7c52c10402ae5d0ae6c0a7dd0f49ef4fd (diff)
parent88882f06f45b07117ed96f6136b25c93f75aad4c (diff)
Merge pull request #18694 from thockin/airplane_validation_pt7
Auto commit by PR queue bot
-rw-r--r--api-conventions.md30
1 files changed, 30 insertions, 0 deletions
diff --git a/api-conventions.md b/api-conventions.md
index a6314f0b..1fe165a6 100644
--- a/api-conventions.md
+++ b/api-conventions.md
@@ -76,6 +76,7 @@ using resources with kubectl can be found in [Working with resources](../user-gu
- [Naming conventions](#naming-conventions)
- [Label, selector, and annotation conventions](#label-selector-and-annotation-conventions)
- [WebSockets and SPDY](#websockets-and-spdy)
+ - [Validation](#validation)
<!-- END MUNGE: GENERATED_TOC -->
@@ -787,6 +788,35 @@ There are two primary protocols in use today:
Clients should use the SPDY protocols if their clients have native support, or WebSockets as a fallback. Note that WebSockets is susceptible to Head-of-Line blocking and so clients must read and process each message sequentionally. In the future, an HTTP/2 implementation will be exposed that deprecates SPDY.
+## Validation
+
+API objects are validated upon receipt by the apiserver. Validation errors are
+flagged and returned to the caller in a `Failure` status with `reason` set to
+`Invalid`. In order to facilitate consistent error messages, we ask that
+validation logic adheres to the following guidelines whenever possible (though
+exceptional cases will exist).
+
+* Be as precise as possible.
+* Telling users what they CAN do is more useful than telling them what they
+ CANNOT do.
+* When asserting a requirement in the positive, use "must". Examples: "must be
+ greater than 0", "must match regex '[a-z]+'". Words like "should" imply that
+ the assertion is optional, and must be avoided.
+* When asserting a formatting requirement in the negative, use "must not".
+ Example: "must not contain '..'". Words like "should not" imply that the
+ assertion is optional, and must be avoided.
+* When asserting a behavioral requirement in the negative, use "may not".
+ Examples: "may not be specified when otherField is empty", "only `name` may be
+ specified".
+* When referencing a literal string value, indicate the literal in
+ single-quotes. Example: "must not contain '..'".
+* When referencing another field name, indicate the name in back-quotes.
+ Example: "must be greater than `request`".
+* When specifying inequalities, use words rather than symbols. Examples: "must
+ be less than 256", "must be greater than or equal to 0". Do not use words
+ like "larger than", "bigger than", "more than", "higher than", etc.
+* When specifying numeric ranges, use inclusive ranges when possible.
+
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/devel/api-conventions.md?pixel)]()
<!-- END MUNGE: GENERATED_ANALYTICS -->