public bool Validate() { ErrorSummary = string.Empty; Validator.RemoveAllRules(); Validator.AddRule( nameof(Mode), () => RuleResult.Assert( !Mode.IsNullOrEmpty(), $"{nameof(Mode)} is required" ) ); Validator.AddRule( nameof(Outcome), () => RuleResult.Assert( !Outcome.IsNullOrEmpty(), $"{nameof(Outcome)} is required" ) ); Validator.AddRule( nameof(Date), () => RuleResult.Assert( Date <= DateTime.Today, $"{nameof(Date)} should be a valid date" ) ); if (EnableConsent) { Validator.AddRule( nameof(Consent), () => RuleResult.Assert( !Consent.IsNullOrEmpty(), $"{nameof(Consent)} is required" ) ); Validator.AddRule( nameof(BookingDate), () => RuleResult.Assert( BookingDate >= DateTime.Today, $"{nameof(BookingDate)} should be a valid date" ) ); } var result = Validator.ValidateAll(); Errors = result.AsObservableDictionary(); if (null != Errors && Errors.Count > 0) { ErrorSummary = Errors.First().Value; } return(result.IsValid); }