public AuthenticationValidator(IValidationMessageProvider validationMessageProvider)
 {
     RuleFor(x => x.UserName)
     .NotEmpty()
     .WithMessage(validationMessageProvider.Get(ValidationMessageKeys.Authentication_UserName_Required));
     RuleFor(x => x.Password)
     .NotEmpty()
     .WithMessage(validationMessageProvider.Get(ValidationMessageKeys.Authentication_Password_Required));
 }
 public AccountService(
     IValidationService validationService, 
     IAccountDao accountDao, 
     IEncryptionService encryptionService, 
     IValidationMessageProvider validationMessageProvider)
 {
     this.validationService = validationService;
     this.accountDao = accountDao;
     this.encryptionService = encryptionService;
     this.validationMessageProvider = validationMessageProvider;
 }
예제 #3
0
 public AccountService(
     IValidationService validationService,
     IAccountDao accountDao,
     IEncryptionService encryptionService,
     IValidationMessageProvider validationMessageProvider)
 {
     this.validationService         = validationService;
     this.accountDao                = accountDao;
     this.encryptionService         = encryptionService;
     this.validationMessageProvider = validationMessageProvider;
 }
 public LocalizedModelValidatorProvider(
     IValidationAttributeAdaptorFactory adapterFactory,
     IValidationMessageProvider validationMessageDataSource
     )
 {
     if (adapterFactory == null)
         throw new ArgumentNullException("adapterFactory");
     if (validationMessageDataSource == null)
         throw new ArgumentNullException("validationMessageDataSource");
     this.adapterFactory = adapterFactory;
     this.validationMessageDataSource = validationMessageDataSource;
 }
 public LocalizedModelValidatorProvider(
     IValidationAttributeAdaptorFactory adapterFactory,
     IValidationMessageProvider validationMessageDataSource
     )
 {
     if (adapterFactory == null)
     {
         throw new ArgumentNullException("adapterFactory");
     }
     if (validationMessageDataSource == null)
     {
         throw new ArgumentNullException("validationMessageDataSource");
     }
     this.adapterFactory = adapterFactory;
     this.validationMessageDataSource = validationMessageDataSource;
 }
예제 #6
0
 public CharacterEditModelValidator(ICharacterDao characterDao, IValidationMessageProvider validationMessageProvider)
 {
     this.characterDao = characterDao;
     RuleFor(x => x.Name)
     .NotEmpty()
     .WithMessage(validationMessageProvider.Get(ValidationMessageKeys.CharacterEdit_Name_Required))
     .Matches("^[a-zA-Z ]+$")
     .WithMessage(validationMessageProvider.Get(ValidationMessageKeys.CharacterEdit_Name_Special_Characters))
     .Must((model, name) => BeUnique(model))
     .WithMessage(validationMessageProvider.Get(ValidationMessageKeys.CharacterEdit_Name_Must_Be_Unique));
     RuleFor(x => x.Price)
     .InclusiveBetween(5, 25)
     .WithMessage(validationMessageProvider.Get(ValidationMessageKeys.CharacterEdit_Price_Boundaries));
     RuleFor(x => x.Type)
     .NotEmpty()
     .WithMessage(validationMessageProvider.Get(ValidationMessageKeys.CharacterEdit_Type_Required));
 }
예제 #7
0
 /// <summary>
 /// Aplica a validação.
 /// </summary>
 /// <param name="currentTarget"></param>
 /// <param name="propertyName"></param>
 /// <param name="propertyLabel"></param>
 /// <param name="objectToValidate"></param>
 /// <param name="validationResults"></param>
 /// <param name="messageProvider"></param>
 public void DoValidate(object currentTarget, string propertyName, IPropertyLabel propertyLabel, object objectToValidate, ValidationResult validationResults, IValidationMessageProvider messageProvider)
 {
     if (objectToValidate == null)
     {
         validationResults.Invalid(ValidationResultType.Error, ResourceMessageFormatter.Create(() => Properties.Resources.Validators_NotNullValidator_MessageTemplate, ((propertyLabel != null) && (propertyLabel.Title != null) && (!String.IsNullOrWhiteSpace(propertyLabel.Title.Format()))) ? propertyLabel.Title : propertyName.GetFormatter(), ValidatorsHelper.GetCurrentTargetName(currentTarget)));
     }
 }
 public ValidationService(ICharacterDao characterDao, IValidationMessageProvider validationMessageProvider)
 {
     authenticationValidator     = new AuthenticationValidator(validationMessageProvider);
     characterEditModelValidator = new CharacterEditModelValidator(characterDao, validationMessageProvider);
 }
 /// <summary>
 /// Construtorn padrão.
 /// </summary>
 /// <param name="propertyName"></param>
 /// <param name="validators"></param>
 /// <param name="validationMessageProvider"></param>
 public PropertyValidationInfo(string propertyName, Func <IValidator>[] validators, IValidationMessageProvider validationMessageProvider)
 {
     _propertyName = propertyName;
     _validators   = validators.Select(f => new Lazy <IValidator>(f)).ToArray();
     _validationMessageProvider = validationMessageProvider;
 }
 public ValidationService(ICharacterDao characterDao, IValidationMessageProvider validationMessageProvider)
 {
     authenticationValidator = new AuthenticationValidator(validationMessageProvider);
     characterEditModelValidator = new CharacterEditModelValidator(characterDao, validationMessageProvider);
 }
예제 #11
0
        /// <summary>
        /// Valida.
        /// </summary>
        /// <param name="currentTarget"></param>
        /// <param name="propertyName"></param>
        /// <param name="propertyLabel"></param>
        /// <param name="objectToValidate"></param>
        /// <param name="validationResults"></param>
        /// <param name="messageProvider"></param>
        public void DoValidate(object currentTarget, string propertyName, IPropertyLabel propertyLabel, object objectToValidate, ValidationResult validationResults, IValidationMessageProvider messageProvider)
        {
            var text = (objectToValidate ?? "").ToString();

            if (_trimString)
            {
                text = text.Trim();
            }
            if (text.Length > _length)
            {
                validationResults.Invalid(ValidationResultType.Error, ResourceMessageFormatter.Create(() => Properties.Resources.Validators_StringLengthValidation_MessageTemplate, ((propertyLabel != null) && (propertyLabel.Title != null) && (!String.IsNullOrWhiteSpace(propertyLabel.Title.Format()))) ? propertyLabel.Title : propertyName.GetFormatter(), ValidatorsHelper.GetCurrentTargetName(currentTarget)));
            }
        }
예제 #12
0
 /// <summary>
 /// Realiza a validação.
 /// </summary>
 /// <param name="currentTarget"></param>
 /// <param name="propertyName"></param>
 /// <param name="propertyLabel"></param>
 /// <param name="objectToValidate"></param>
 /// <param name="validationResults"></param>
 /// <param name="messageProvider"></param>
 public void DoValidate(object currentTarget, string propertyName, IPropertyLabel propertyLabel, object objectToValidate, ValidationResult validationResults, IValidationMessageProvider messageProvider)
 {
     foreach (var validator in _validators)
     {
         validator.DoValidate(currentTarget, propertyName, propertyLabel, objectToValidate, validationResults, messageProvider);
     }
 }