Пример #1
0
 /// <summary>
 /// Value must conform to a specific regular expression.
 /// </summary>
 /// <param name="builder"><see cref="ValueValidationBuilder{T}"/> to build for.</param>
 /// <param name="expression">The regular expression that the value must conform to.</param>
 /// <returns><see cref="ValueValidationBuilder{T}"/> to continue building on.</returns>
 public static ValueValidationBuilder <string> MustConformToRegularExpressionOf(this ValueValidationBuilder <string> builder, string expression)
 {
     builder.AddRule(new Regex(builder.Property, expression));
     return(builder);
 }
Пример #2
0
 /// <summary>
 /// Value must be less than or equal.
 /// </summary>
 /// <typeparam name="T">Type of value.</typeparam>
 /// <param name="builder"><see cref="ValueValidationBuilder{T}"/> to build for.</param>
 /// <param name="value">Value the input value must be less or equal than.</param>
 /// <returns><see cref="ValueValidationBuilder{T}"/> to continue building on.</returns>
 public static ValueValidationBuilder <T> HasToBeLessThanOrEqual <T>(this ValueValidationBuilder <T> builder, T value)
     where T : IComparable <T>
 {
     builder.AddRule(new LessThanOrEqual <T>(builder.Property, value));
     return(builder);
 }
Пример #3
0
 /// <summary>
 /// Value must be greater than.
 /// </summary>
 /// <typeparam name="T">Type of value.</typeparam>
 /// <param name="builder"><see cref="ValueValidationBuilder{T}"/> to build for.</param>
 /// <param name="value">Value the input value must be greater than.</param>
 /// <returns><see cref="ValueValidationBuilder{T}"/> to continue building on.</returns>
 public static ValueValidationBuilder <T> HasToBeGreaterThan <T>(this ValueValidationBuilder <T> builder, T value)
     where T : IComparable <T>
 {
     builder.AddRule(new GreaterThan <T>(builder.Property, value));
     return(builder);
 }
Пример #4
0
 /// <summary>
 /// String must be a specific length.
 /// </summary>
 /// <param name="builder"><see cref="ValueValidationBuilder{T}"/> to build for.</param>
 /// <param name="length">The length the value must be.</param>
 /// <returns><see cref="ValueValidationBuilder{T}"/> to continue building on.</returns>
 public static ValueValidationBuilder <string> MustHaveMaxLengthOf(this ValueValidationBuilder <string> builder, int length)
 {
     builder.AddRule(new MaxLength(builder.Property, length));
     return(builder);
 }
Пример #5
0
 /// <summary>
 /// Value must be a valid email.
 /// </summary>
 /// <param name="builder"><see cref="ValueValidationBuilder{T}"/> to build for.</param>
 /// <returns><see cref="ValueValidationBuilder{T}"/> to continue building on.</returns>
 public static ValueValidationBuilder <string> MustBeValidEMail(this ValueValidationBuilder <string> builder)
 {
     builder.AddRule(new Email(builder.Property));
     return(builder);
 }