public ValidationBuilder(ValidatorGroup validationGroup)
 {
     if (validationGroup != null)
     {
         Validator = validationGroup;
     }
 }
        public void ValidatorGroup_WhenHasValidators_CountIsCorrect()
        {
            const int EXPECTED_COUNT = 1;

            ValidatorGroup group = new ValidatorGroup();

            group.Add(new UniqueColumnValidator());

            Assert.AreEqual(EXPECTED_COUNT, group.Count());
        }
        /// <summary>
        /// Set <see cref="PropertyObject.Validation"/> of the <see cref="PropertyObject"/>
        /// identified by name.
        /// </summary>
        /// <param name="property">name of <see cref="PropertyObject"/> to update Validation</param>
        /// <param name="option"></param>
        public bool SetValidation(string property, ValidatorGroup validation)
        {
            if (this.FindRecursive(property) is PropertyObject di)
            {
                di.Validation = validation;
                return(true);
            }

            return(false);
        }
        public void Multiple_WhenNoValidators_ReturnsTrue()
        {
            const string INPUT          = "doesnt matter";
            const bool   EXPECTED_VALUE = true;

            ValidatorGroup validators = new ValidatorGroup();

            bool result = validators.IsValid(INPUT);

            Assert.AreEqual(EXPECTED_VALUE, result);
        }
        public void ValidatorGroup_WhenHasValidators_FindReturnsCorrectly()
        {
            TextFormatValidator textValidator = new TextFormatValidator(string.Empty);

            ValidatorGroup group = new ValidatorGroup();

            group.Add(textValidator);

            IValidator validator = group.Find(p => p.GetType() == typeof(TextFormatValidator));

            Assert.AreSame(textValidator, validator);
        }
        public void Multiple_OnSingleValue_IsInvalid()
        {
            const string INPUT           = "test this sting for a number";
            const bool   EXPECTED_RESULT = false;

            ValidatorGroup validators = new ValidatorGroup();

            validators.Add(new StringLengthValidator(9));
            validators.Add(new NumberValidator());

            bool result = validators.IsValid(INPUT);

            Assert.AreEqual(EXPECTED_RESULT, result);
        }
        public DifiCertificateValidator(Mode mode)
        {
            this.mode = mode;

            try
            {
                var file = new FileInfo(mode.GetValue("security.pki"));
                this.validator = ValidatorLoader.NewInstance().Build(file);
            }
            catch (ValidatorParsingException e)
            {
                throw new PeppolLoadingException("Unable to initiate PKI.", e);
            }
        }
Example #8
0
 private void BaseEditRole_Load(object sender, EventArgs e)
 {
     ValidatorGroup name = new ValidatorGroup("txbName", new EmptyValidator("请输入角色名称"));
     this.ValidationManager.AddValidatorGroup(name);
 }
Example #9
0
        private void BaseEditHouse_Load(object sender, EventArgs e)
        {
            cmbHall.SelectedIndex = 0;
            cmbRoom.SelectedIndex = 0;
            cmbToilet.SelectedIndex = 0;
            ValidatorGroup housename = new ValidatorGroup("txbHouseName", new EmptyValidator("请输入房间名称"));
            ValidatorGroup cycle = new ValidatorGroup("txbArea", new EmptyValidator("请输入面积"));

            this.ValidationManager.AddValidatorGroup(housename);
            this.ValidationManager.AddValidatorGroup(cycle);
        }
 public NumericPropertyObjectBuilder <T> SetValidation(ValidatorGroup validation)
 {
     prop.Validation = validation;
     return(this);
 }
 public virtual PropertyObjectBuilder SetValidation(ValidatorGroup validation)
 {
     prop.Validation = validation;
     return(this);
 }