public static Notification Invalid() { var returnValue = new Notification(); returnValue.RegisterFailure("something", "something else"); return returnValue; }
protected override void validate(object target, object rawValue, Notification notification) { if (rawValue == null || (rawValue.ToString().Trim() == string.Empty) ) { logMessage(notification, message()); } }
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); }
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); }
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; }
public Notification Flatten() { var list = new List<ValidationFailure>(); gather(list); var returnValue = new Notification(); returnValue._list.AddRange(list); return returnValue; }
public void Include(Notification peer) { _list.AddRange(peer.AllFailures); }