You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 42d73fe
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: website/docs/language/expressions/custom-data-validation.mdx
+5-7Lines changed: 5 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,13 @@ description: >-
6
6
7
7
# Custom Data Validation
8
8
9
-
You can create validation checks for configuration requirements that return detailed error messages to consumers. Custom validations are optional, but they can help capture assumptions that might be only implied, helping future maintainers understand the configuration design and intent. They also return useful information about errors earlier and in context, helping consumers more easily diagnose issues in their configurations.
9
+
You can create validation checks with custom error messages for several types of objects in a configuration. Custom validations are optional, but they can help capture assumptions that might be only implied, helping future maintainers understand the configuration design and intent. They also return useful information about errors earlier and in context, helping consumers more easily diagnose issues in their configurations.
10
10
11
11
You can create custom validations with the following types of expressions.
- Add []`precondition` and `postcondition`](#preconditions-and-postconditions) blocks inside `lifecycle` blocks and `precondition` blocks inside `output blocks`.
13
+
- Add [`precondition` and `postcondition`](#preconditions-and-postconditions) blocks inside `lifecycle` blocks and `precondition` blocks inside `output blocks`.
14
14
15
-
The `validation`, `precondition`, and `postcondition` blocks all require a [`condition` attribute](#condition-expressions) that describes the validation requirements and an [`error_message` attribute](#error-messages) that contains explanatory text that Terraform will display to the user.
15
+
All of these methods require a [`condition` attribute](#condition-expressions) that describes the validation requirements and an [`error_message` attribute](#error-messages) that contains explanatory text that Terraform will display to the user.
16
16
17
17
-> **Note:** Input variable validation is available in Terraform CLI v0.13.0 and later. Preconditions and postconditions are available in Terraform CLI v1.2.0 and later.
18
18
@@ -135,7 +135,7 @@ We recommend also considering the following factors.
135
135
- Whether it is helpful to declare the same or similar conditions as both preconditions and postconditions. This can be useful if the postcondition is in a different module than the precondition because it lets the modules verify one another as they evolve independently.
136
136
137
137
138
-
## Usage Examples
138
+
###Usage Examples
139
139
140
140
The following example shows possible uses for variable validation, preconditions and postconditions.
141
141
@@ -245,7 +245,7 @@ The preconditions, and postconditions declare the following assumptions and guar
245
245
problem immediately, before any other components rely on the
246
246
insecurely-configured component.
247
247
248
-
## Condition Expressions
248
+
## Condition Expressions
249
249
250
250
The variable `validation` block and the `precondition` and `postcondition` blocks all require an argument named `condition`, whose value is a boolean expression which should return `true` if the intended assumption holds or `false` if it does not.
251
251
@@ -257,8 +257,6 @@ Condition expressions have the following requirements.
257
257
You can use any of Terraform's built-in functions or language operators
258
258
in a condition as long as the expression is valid and returns a boolean result.
259
259
260
-
## Common Condition Expression Features
261
-
262
260
Because condition expressions must produce boolean results, they can often
263
261
use built-in functions and language features that are less common elsewhere
264
262
in the Terraform language. The following language features are particularly
0 commit comments