# How to call a domain logic function inside pre-condition?

PREREQUISITE


  1. Define a reference variable to the domain logic inside the command-set.


     



    command-set Lottery {
    	domain-logic-ref lotteryDomainLogicRef:Lottery
      ...
    }
    
  2. Call the respective domain function using the reference variable inside the pre condition






     






    command-set Lottery {
    	domain-logic-ref lotteryDomainLogicRef:Lottery
      command create{
          input(lotteryName:String,amount:Int)
          pre{
            condition NewLotteryName => !(lotteryDomainLogicRef.lotteryNameExists(input.lotteryName)) failing "Lottery Name Already Exists !"
            ...
          }
          ...
    	}
    }