-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathTransactionArgsValidator.cs
24 lines (21 loc) · 1.09 KB
/
TransactionArgsValidator.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
namespace Cdr.Banking.Business.Validation;
/// <summary>
/// Represents a <see cref="TransactionArgs"/> validator.
/// </summary>
public class TransactionArgsValidator : Validator<TransactionArgs>
{
/// <summary>
/// Initializes a new instance of the <see cref="TransactionArgsValidator"/>.
/// </summary>
public TransactionArgsValidator()
{
// Default FromDate where not provided, as 90 days less than ToDate; where no ToDate then assume today (now). Make sure FromDate is not greater than ToDate.
Property(x => x.FromDate)
.Default(a => (a.ToDate!.HasValue ? a.ToDate.Value : SystemTime.Timestamp).AddDays(-90))
.CompareProperty(CompareOperator.LessThanEqual, y => y.ToDate).DependsOn(y => y.ToDate);
// Make sure MinAmount is not greater than MaxAmount.
Property(x => x.MinAmount).CompareProperty(CompareOperator.LessThanEqual, y => y.MaxAmount).DependsOn(y => y.MaxAmount);
// Make sure the Text does not include the '*' wildcard character.
Property(x => x.Text).Wildcard(CoreEx.Wildcards.Wildcard.None);
}
}