BCPNFR21 - User-defined types - Decorators
ID: BCPNFR21 - User-defined types - Decorators
User-defined types (UDTs) and each of their properties MUST have a @description() decorator.
Apply the secure input requirements in BCPNFR9 to UDT properties as well as parameters. If a UDT has both sensitive and non-sensitive properties, mark each sensitive string property with @secure(). You can mark an object property @secure() only if all of its properties are sensitive. Do not mark an object, property, or parameter @secure() if it contains any non-sensitive properties, because this marks everything inside it as secure too.
@secure() works only on strings and objects, not arrays. For an array of objects, mark the secure properties on the item type, not on the array.
UDTs SHOULD also use constraints such as minValue, maxValue, minLength, and maxLength to improve usability.
In this example, the parent marks the password property as secure and passes it to the child’s secure accountPassword parameter. The name property and accountName parameter both stay non-secure.
Parent module:
@description('The settings for an account.')
type account = {
@description('The account name.')
@minLength(1)
name: string
@description('The account password.')
@secure()
password: string
}
@description('Required. The accounts to configure.')
param accounts account[]
module accountDeployments 'account.bicep' = [for account in accounts: {
params: {
accountName: account.name
accountPassword: account.password
}
}]Child module inputs (account.bicep):
@description('Required. The account name.')
param accountName string
@description('Required. The account password.')
@secure()
param accountPassword string