Example #1
0
        public ChangeLocationBusinessValidator(IDataCollectorRules dataCollectorRules)
        {
            _dataCollectorRules = dataCollectorRules;

            RuleFor(_ => _.DataCollectorId)
            .Must(BeRegistered).WithMessage(_ => $"Data Collector with id {_.DataCollectorId.Value} is not registered");
        }
Example #2
0
        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));
        }
Example #3
0
        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");
        }