Class ValidationHelpers
A set of helper methods for validation
Methods
CreateRestrictions<TEntity>(Expression<Func<TEntity, String>>, Int32, Int32)
Shortcut for creating string restrictions
Declaration
public static StringLengthRestriction<TEntity> CreateRestrictions<TEntity>(Expression<Func<TEntity, string>> selector, int minimumLength, int maximumLength)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<TEntity, System.String>> | selector | The selector |
System.Int32 | minimumLength | The min length |
System.Int32 | maximumLength | The max length |
Returns
Type | Description |
---|---|
StringLengthRestriction<TEntity> | The restriction |
Type Parameters
Name | Description |
---|---|
TEntity | The entity type |
GetDefaultForComparison(Type)
Gets or creates an empty instance of a TType for comparison
Declaration
public static IComparable GetDefaultForComparison(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type |
Returns
Type | Description |
---|---|
System.IComparable | The empty instance |
NoDuplicates<TSource, TTarget>(IRuleBuilder<TSource, ICollection<TTarget>>, Expression<Func<TTarget, IComparable>>[])
Validates that no duplicates are present in the collection
Declaration
public static IRuleBuilderOptions<TSource, ICollection<TTarget>> NoDuplicates<TSource, TTarget>(this IRuleBuilder<TSource, ICollection<TTarget>> ruleBuilder, params Expression<Func<TTarget, IComparable>>[] identitySelectors)
Parameters
Type | Name | Description |
---|---|---|
FluentValidation.IRuleBuilder<TSource, System.Collections.Generic.ICollection<TTarget>> | ruleBuilder | The source rule builder |
System.Linq.Expressions.Expression<System.Func<TTarget, System.IComparable>>[] | identitySelectors | The identity selectors |
Returns
Type | Description |
---|---|
FluentValidation.IRuleBuilderOptions<TSource, System.Collections.Generic.ICollection<TTarget>> | The rule builder |
Type Parameters
Name | Description |
---|---|
TSource | The source type |
TTarget | The collection item type |