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
Detail: "An empty string is not a valid nor useful error message.",
124
-
Subject: attr.Expr.Range().Ptr(),
125
-
})
126
-
case!looksLikeSentences(cr.ErrorMessage):
127
-
// Because we're going to include this string verbatim as part
128
-
// of a bigger error message written in our usual style in
129
-
// English, we'll require the given error message to conform
130
-
// to that. We might relax this in future if e.g. we start
131
-
// presenting these error messages in a different way, or if
132
-
// Terraform starts supporting producing error messages in
133
-
// other human languages, etc.
134
-
// For pragmatism we also allow sentences ending with
135
-
// exclamation points, but we don't mention it explicitly here
136
-
// because that's not really consistent with the Terraform UI
137
-
// writing style.
138
-
diags=diags.Append(&hcl.Diagnostic{
139
-
Severity: hcl.DiagError,
140
-
Summary: errSummary,
141
-
Detail: "The validation error message must be at least one full sentence starting with an uppercase letter and ending with a period or question mark.\n\nYour given message will be included as part of a larger Terraform error message, written as English prose. For broadly-shared modules we suggest using a similar writing style so that the overall result will be consistent.",
142
-
Subject: attr.Expr.Range().Ptr(),
143
-
})
144
-
}
145
-
}
115
+
cr.ErrorMessage=attr.Expr
146
116
}
147
117
148
118
returncr, diags
149
119
}
150
120
151
-
// looksLikeSentence is a simple heuristic that encourages writing error
152
-
// messages that will be presentable when included as part of a larger
153
-
// Terraform error diagnostic whose other text is written in the Terraform
154
-
// UI writing style.
155
-
//
156
-
// This is intentionally not a very strong validation since we're assuming
157
-
// that module authors want to write good messages and might just need a nudge
158
-
// about Terraform's specific style, rather than that they are going to try
159
-
// to work around these rules to write a lower-quality message.
160
-
funclooksLikeSentences(sstring) bool {
161
-
iflen(s) <1 {
162
-
returnfalse
163
-
}
164
-
runes:= []rune(s) // HCL guarantees that all strings are valid UTF-8
165
-
first:=runes[0]
166
-
last:=runes[len(runes)-1]
167
-
168
-
// If the first rune is a letter then it must be an uppercase letter.
169
-
// (This will only see the first rune in a multi-rune combining sequence,
170
-
// but the first rune is generally the letter if any are, and if not then
171
-
// we'll just ignore it because we're primarily expecting English messages
172
-
// right now anyway, for consistency with all of Terraform's other output.)
0 commit comments