| | | 1 | | // ReSharper disable once CheckNamespace |
| | | 2 | | namespace FluentValidation; |
| | | 3 | | |
| | | 4 | | /// <summary>Rules for Hijri date text (see <see cref="HijriDate.IsHijriDate"/>).</summary> |
| | | 5 | | public static class FluentValidationHijriDateHelpers |
| | | 6 | | { |
| | | 7 | | /// <summary>The text must be a Hijri date.</summary> |
| | | 8 | | /// <typeparam name="T">The validated type.</typeparam> |
| | | 9 | | /// <param name="ruleBuilder">The rule builder.</param> |
| | | 10 | | /// <returns>The rule builder options.</returns> |
| | 18 | 11 | | public static IRuleBuilderOptions<T, string> IsHijriDate< T >( this IRuleBuilder<T, string> ruleBuilder ) => ruleBui |
| | | 12 | | |
| | | 13 | | /// <summary>Checks that <paramref name="value"/> is a Hijri date.</summary> |
| | | 14 | | /// <param name="value">The text.</param> |
| | | 15 | | /// <returns><see langword="true"/> when it is a Hijri date.</returns> |
| | 27 | 16 | | public static bool IsHijriDate( string? value ) => HijriDate.IsHijriDate( value ); |
| | | 17 | | |
| | | 18 | | /// <summary>The text must be empty or a Hijri date.</summary> |
| | | 19 | | /// <typeparam name="T">The validated type.</typeparam> |
| | | 20 | | /// <param name="ruleBuilder">The rule builder.</param> |
| | | 21 | | /// <returns>The rule builder options.</returns> |
| | | 22 | | public static IRuleBuilderOptions<T, string> IsNullableHijriDate< T >( this IRuleBuilder<T, string> ruleBuilder ) |
| | 12 | 23 | | => ruleBuilder.Must( value => string.IsNullOrWhiteSpace( value ) || IsHijriDate( value ) ).WithErrorCode( nameof |
| | | 24 | | } |