Parameter validation using fail
              
              #16248
            
            
                  
                    
                      ReubenFrankel
                    
                  
                
                  started this conversation in
                Authoring Help
              
            Replies: 2 comments 3 replies
-
| Additionally, I cannot define multiple validation expressions that assign to the same stub  #disable-next-line no-unused-vars
var _ = empty(param1) && empty(param2) && fail('paramA or paramB must be provided')
#disable-next-line no-unused-vars
var _ = !empty(param1) && !empty(param2) && fail('Only one of paramA and paramB should be provided')#disable-next-line no-unused-vars
var _ = empty(param1) && empty(param2) && fail('paramA or paramB must be provided')
_ = !empty(param1) && !empty(param2) && fail('Only one of paramA and paramB should be provided') | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            -
| All values in Bicep are immutable, so reassignments are blocked. You can use an array if you need a series of assertions; the following will compile: var __assertions = [
  empty(param1) && empty(param2) && fail('paramA or paramB must be provided')
  !empty(param1) && !empty(param2) && fail('Only one of paramA and paramB should be provided')
]The language doesn't really have standalone statements, so the expressions do need to be part of a declaration of some kind. | 
Beta Was this translation helpful? Give feedback.
                  
                    3 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
is it possible to perform simple parameter validation with the new
failfunction without some kind of assignment (i.e an empty expression)?This works
but these
result in compilation errors.
I was looking to see if docs covered this but can't find any on
fail: https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/operators-logical: https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/bicep-functionsBeta Was this translation helpful? Give feedback.
All reactions