public ChangeLocationBusinessValidator(IDataCollectorRules dataCollectorRules) { _dataCollectorRules = dataCollectorRules; RuleFor(_ => _.DataCollectorId) .Must(BeRegistered).WithMessage(_ => $"Data Collector with id {_.DataCollectorId.Value} is not registered"); }
public RemovePhoneNumberFromDataCollectorBusinessValidator(IDataCollectorRules dataCollectorRules, IPhoneNumberRules phoneNumberRules) { _dataCollectorRules = dataCollectorRules; _phoneNumberRules = phoneNumberRules; RuleFor(_ => _.DataCollectorId) .Must(BeRegistered).WithMessage(_ => $"Data Collector with id {_.DataCollectorId.Value} is not registered"); RuleFor(_ => _.PhoneNumber) .SetValidator(new PhoneNumberIsRegisteredValidator(_phoneNumberRules)); }
public ChangeBaseInformationBusinessValidator(IDataCollectorRules dataCollectorRules) { _dataCollectorRules = dataCollectorRules; RuleFor(_ => _.DataCollectorId) .Must(BeRegistered).WithMessage(_ => $"Data Collector with id {_.DataCollectorId.Value} is not registered"); RuleFor(command => command) // New display name must not be taken .Must(_dataCollectorRules.DataCollectorCanChangeDisplayName) .WithMessage(_ => $"Datacollector display name {_.DisplayName} is already taken, choose another"); }
public RegisterDataCollectorBusinessValidator(IDataCollectorRules dataCollectorRules, IPhoneNumberRules phoneNumberRules) { _dataCollectorRules = dataCollectorRules; _phoneNumberRules = phoneNumberRules; RuleFor(_ => _.DataCollectorId) .Must(NotBeRegistered).WithMessage("Datacollector with same id is already registered"); RuleFor(_ => _.PhoneNumbers) .SetCollectionValidator(new PhoneNumberIsNotRegisteredValidator(_phoneNumberRules)); RuleFor(_ => _.DisplayName) .Must(DisplayNameNotTaken).WithMessage(_ => $"Datacollector display name {_.DisplayName} is already taken, choose another"); }