2

Similar to how a Bicep Module input parameter can be validated (e.g. allowed string length), is it possible to validate a string variable's length?

param input1 string
param input2 string

var combo = '${input1}${input2}' 

// Validate length of 'combo' to be below or equal to 64 characters here 

The reason is that I want to be able to catch resource deployment names that are too long (over 64 characters) during pre-flight validation.

Thomas
  • 24,234
  • 6
  • 81
  • 125

1 Answers1

2

Not sure it is possible for variables but you could always define combo as a parameter and add a maxLength decorator:

param input1 string
param input2 string

@maxLength(64)
param combo string = '${input1}${input2}' 
Thomas
  • 24,234
  • 6
  • 81
  • 125
  • 1
    New to Bicep so never thought of the possibility of referencing other params as default values, thanks! Hoping to be able to solve this in the future by combining conditional statements with throwing, but this will work for now – Isak Engström Sep 23 '22 at 06:40