mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-07 22:53:08 -06:00
e999ae77ba
This commit adds ValidateFunc to the policy attribute so that JSON parsing errors can be caught early. Generally, when there is a ValidateFunc set for the attribute, one can safely assume that before any of the creation and/or update of the existing resource would happen it would have to succeed validation. Also adds support for new helper function which is used to normalise JSON string. Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
11 lines
257 B
Go
11 lines
257 B
Go
package azurerm
|
|
|
|
import "fmt"
|
|
|
|
func validateJsonString(v interface{}, k string) (ws []string, errors []error) {
|
|
if _, err := normalizeJsonString(v); err != nil {
|
|
errors = append(errors, fmt.Errorf("%q contains an invalid JSON: %s", k, err))
|
|
}
|
|
return
|
|
}
|