public void ExecuteCommand(ValidationCommandContext context)
        {
            bool   condition    = Condition.Invoke();
            object value        = RequiredProperty.Compile().Invoke();
            var    propertyName = RequiredProperty.GetPropertyName();

            if (value == null && condition)
            {
                context.AddError(new ValidationResult(ErrorMessage, new[] { propertyName }));
            }
        }
예제 #2
0
        public void ExecuteCommand(ValidationCommandContext context)
        {
            bool condition = Condition.Compile().Invoke();

            if (condition)
            {
                string value = EmailProperty.Compile().Invoke();
                if (!CheckIfEmail(value))
                {
                    var propertyName = EmailProperty.GetPropertyName();
                    context.AddError(new ValidationResult(ErrorMessage, new[] { propertyName }));
                }
            }
        }
        public void ExecuteCommand(ValidationCommandContext context)
        {
            object value        = PropertyRequired.Compile().Invoke();
            var    propertyName = PropertyRequired.GetPropertyName();

            bool result = value == null;

            if (value is string)
            {
                result = string.IsNullOrWhiteSpace(value as string);
            }

            if (result)
            {
                context.AddError(new ValidationResult(ErrorMessage, new[] { propertyName }));
            }
        }
 protected void Act(IValidationCommand rule)
 {
     _context = new ValidationCommandContext();
     rule.ExecuteCommand(_context);
 }