Beispiel #1
0
 /// <summary>
 /// Adds a validation message if the current validatable object is empty.
 /// </summary>
 /// <param name="valObj">The value object.</param>
 /// <returns></returns>
 public static FluentValidationObject <string> IsNotEmpty(
     this FluentValidationObject <string> valObj
     )
 {
     if (valObj.ValidatableObject != null && String.IsNullOrEmpty(valObj.ValidatableObject))
     {
         valObj.AddValidationMessage(Messages.IsEmpty);
     }
     return(valObj);
 }
Beispiel #2
0
 /// <summary>
 /// Adds a validation message if the current validatable object is null.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="valObj">The value object.</param>
 /// <returns></returns>
 public static FluentValidationObject <T> IsNotNull <T>(
     this FluentValidationObject <T> valObj
     )
     where T : class
 {
     if (valObj.ValidatableObject == null)
     {
         valObj.AddValidationMessage(Messages.IsNull);
     }
     return(valObj);
 }
Beispiel #3
0
 /// <summary>
 /// Adds a validation message if the current validatable object is not equal to <paramref name="otherObject"/>.
 /// </summary>
 /// <param name="valObj">The value object.</param>
 /// <param name="otherObject">The other object.</param>
 /// <returns></returns>
 public static FluentValidationObject <T> IsEqualTo <T>(
     this FluentValidationObject <T> valObj,
     T otherObject
     )
     where T : IComparable <T>
 {
     if (valObj.ValidatableObject.CompareTo(otherObject) == 0)
     {
         valObj.AddValidationMessage(Messages.IsNotEqualTo);
     }
     return(valObj);
 }
Beispiel #4
0
 /// <summary>
 /// Adds a validation message if the current validatable object is not smaller then <paramref name="max"/>.
 /// </summary>
 /// <param name="valObj">The value object.</param>
 /// <param name="max"></param>
 /// <returns></returns>
 public static FluentValidationObject <T> IsSmallerThen <T>(
     this FluentValidationObject <T> valObj,
     T max
     )
     where T : IComparable <T>
 {
     if (valObj.ValidatableObject.CompareTo(max) > 0)
     {
         valObj.AddValidationMessage(String.Format(Messages.IsBiggerThen, max));
     }
     return(valObj);
 }
Beispiel #5
0
 /// <summary>
 /// Adds a validation message if the current validatable object is not smaller then <paramref name="max"/>.
 /// </summary>
 /// <param name="valObj">The value object.</param>
 /// <param name="max"></param>
 /// <returns></returns>
 public static FluentValidationObject <IEnumerable <T> > IsSmallerThen <T>(
     this FluentValidationObject <IEnumerable <T> > valObj,
     int max
     )
 {
     if (valObj.ValidatableObject != null)
     {
         int count = valObj.ValidatableObject.Count();
         if (count > max)
         {
             valObj.AddValidationMessage(String.Format(Messages.IsBiggerThen, max));
         }
     }
     return(valObj);
 }