# What to write a complex validation?
Use
letto hold computed properties insidepreblockpre{ let participantCount:Int = `domainLogicRef.lottery.participantCount(input.lotteryName)` condition atLeastTwoParticipants => existingLotteryName -> ` participantCount > 1` failing "The lottery does not have any participant!" }To execute a check only when a pervious condition passes use the condition name with
->operator.pre{ condition existingLotteryName => lottery.lotteryNameExists(input.lotteryName) condition openToRun => existingLotteryName -> lottery.isOpenToRun(input.lotteryName) }To execute a condition only when an optional input's value exists use keyword
presentalong with->operator.command addParticipant{ input(lotteryName:String,participantName:String,email:String?) pre{ condition validEmail => present(input.email) -> lottery.validateEmail(input.email.dig) } }Use
!to apply negation inside the condition logicpre{ condition NewLotteryName => !(lottery.lotteryNameExists(input.lotteryName)) failing "Lottery Name Already Exists !" ... }