Ejemplo n.º 1
0
        public static Notification Invalid()
        {
            var returnValue = new Notification();
            returnValue.RegisterFailure("something", "something else");

            return returnValue;
        }
Ejemplo n.º 2
0
 protected override void validate(object target, object rawValue, Notification notification)
 {
     if (rawValue == null || (rawValue.ToString().Trim() == string.Empty) )
     {
         logMessage(notification, message());
     }
 }
Ejemplo n.º 3
0
 public void AddChild(string propertyName, Notification notification)
 {
     if (_children.ContainsKey(propertyName))
     {
         _children[propertyName] = notification;
     }
     else
     {
         _children.Add(propertyName, notification);
     }
 }
        protected override void validate(object target, object rawValue, Notification notification)
        {
            if (rawValue == null)
            {
                return;
            }

            if (rawValue.ToString().Length <= _length) return;
            var message = string.Format("[{0}] cannot be longer than {1} characters", PropertyName, _length);
            logMessage(notification, message);
        }
Ejemplo n.º 5
0
        public static ValidationFailure[] ValidateField(object target, string propertyName)
        {
            var atts = scanType(target.GetType());
            var list = atts.FindAll(att => att.PropertyName == propertyName);

            var notification = new Notification();
            foreach (var attribute in list)
            {
                attribute.Validate(target, notification);
            }

            if (target is IValidated)
            {
                ((IValidated)target).Validate(notification);
            }

            return notification.GetFailures(propertyName);
        }
Ejemplo n.º 6
0
        public static Notification ValidateObject(object target)
        {
            if (target == null)
            {
                return new Notification();
            }

            var atts = scanType(target.GetType());
            var notification = new Notification();

            if (target is IValidated)
            {
                ((IValidated)target).Validate(notification);
            }

            foreach (ValidationAttribute att in atts)
            {
                att.Validate(target, notification);
            }

            return notification;
        }
Ejemplo n.º 7
0
        public Notification Flatten()
        {
            var list = new List<ValidationFailure>();
            gather(list);

            var returnValue = new Notification();
            returnValue._list.AddRange(list);

            return returnValue;
        }
Ejemplo n.º 8
0
 public void Include(Notification peer)
 {
     _list.AddRange(peer.AllFailures);
 }