Skip to content

Commit a552fa4

Browse files
Shikha MaheshwariShikha Maheshwari
authored andcommitted
added code snippet in prefix doc
1 parent a0d63d6 commit a552fa4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/DA-prefix.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,23 @@ To ensure compatibility and consistency, the prefix must follow these rules:
3636
- Must **not end** with a hyphen (`-`)
3737
- Must **not contain consecutive hyphens** (`--`)
3838
- Maximum length: **16 characters**
39+
40+
Here is the code snippet for your reference.
41+
42+
```hcl
43+
validation {
44+
condition = (var.prefix == null || var.prefix == "" ? true :
45+
alltrue([
46+
can(regex("^[a-z][-a-z0-9]*[a-z0-9]$", var.prefix)),
47+
length(regexall("--", var.prefix)) == 0
48+
])
49+
)
50+
error_message = "Prefix must begin with a lowercase letter and may contain only lowercase letters, digits, and hyphens '-'. It must not end with a hyphen('-'), and cannot contain consecutive hyphens ('--')."
51+
}
52+
53+
validation {
54+
# must not exceed 16 characters in length
55+
condition = length(var.prefix) <= 16
56+
error_message = "Prefix must not exceed 16 characters."
57+
}
58+
```

0 commit comments

Comments
 (0)