| | | 1 | | using ZhEaIsNsAaBn.Utilities.FluentValidation; |
| | | 2 | | |
| | | 3 | | // ReSharper disable once CheckNamespace |
| | | 4 | | namespace FluentValidation; |
| | | 5 | | |
| | | 6 | | /// <summary>Mobile-number rules (libphonenumber). Numbers in international form (<c>+966…</c>) or local form for the re |
| | | 7 | | public static class FluentValidationMobileNumber |
| | | 8 | | { |
| | | 9 | | /// <summary>The text must be a valid Saudi (<c>SA</c>) number.</summary> |
| | | 10 | | /// <typeparam name="T">The validated type.</typeparam> |
| | | 11 | | /// <param name="ruleBuilder">The rule builder.</param> |
| | | 12 | | /// <returns>The rule builder options.</returns> |
| | 18 | 13 | | public static IRuleBuilderOptions<T, string> IsKSAMobileNumber< T >( this IRuleBuilder<T, string> ruleBuilder ) => r |
| | | 14 | | |
| | | 15 | | /// <summary>The text must be empty or a valid Saudi (<c>SA</c>) number (<see cref="KSANullableMobileNumberValidator |
| | | 16 | | /// <typeparam name="T">The validated type.</typeparam> |
| | | 17 | | /// <param name="ruleBuilder">The rule builder.</param> |
| | | 18 | | /// <returns>The rule builder options; the error code is <c>IsKSANullableMobileNumber</c>.</returns> |
| | | 19 | | public static IRuleBuilderOptions<T, string> IsKSANullableMobileNumber< T >( this IRuleBuilder<T, string> ruleBuilde |
| | 21 | 20 | | => ruleBuilder.SetValidator( new KSANullableMobileNumberValidator<T>() ).WithErrorCode( nameof( IsKSANullableMob |
| | | 21 | | |
| | | 22 | | /// <summary>The text must be a valid number for <paramref name="regionCode"/>.</summary> |
| | | 23 | | /// <typeparam name="T">The validated type.</typeparam> |
| | | 24 | | /// <param name="ruleBuilder">The rule builder.</param> |
| | | 25 | | /// <param name="regionCode">The ISO 3166 region, e.g. <c>SA</c>.</param> |
| | | 26 | | /// <returns>The rule builder options.</returns> |
| | | 27 | | public static IRuleBuilderOptions<T, string> IsMobileNumber< T >( this IRuleBuilder<T, string> ruleBuilder, string r |
| | 12 | 28 | | => ruleBuilder.SetValidator( new MobileNumberValidator<T>( regionCode ) ).WithErrorCode( nameof( IsMobileNumber |
| | | 29 | | |
| | | 30 | | /// <summary>The text must be a valid number for the region <paramref name="regionCodeFunc"/> returns for the instan |
| | | 31 | | /// <typeparam name="T">The validated type.</typeparam> |
| | | 32 | | /// <param name="ruleBuilder">The rule builder.</param> |
| | | 33 | | /// <param name="regionCodeFunc">Returns the ISO 3166 region for the instance.</param> |
| | | 34 | | /// <returns>The rule builder options.</returns> |
| | | 35 | | public static IRuleBuilderOptions<T, string> IsMobileNumber< T >( this IRuleBuilder<T, string> ruleBuilder, Func<T, |
| | 6 | 36 | | => ruleBuilder.SetValidator( new MobileNumberValidator<T>( regionCodeFunc ) ).WithErrorCode( nameof( IsMobileNum |
| | | 37 | | |
| | | 38 | | /// <summary>The text must be empty or a valid number for <paramref name="regionCode"/>.</summary> |
| | | 39 | | /// <typeparam name="T">The validated type.</typeparam> |
| | | 40 | | /// <param name="ruleBuilder">The rule builder.</param> |
| | | 41 | | /// <param name="regionCode">The ISO 3166 region, e.g. <c>SA</c>.</param> |
| | | 42 | | /// <returns>The rule builder options.</returns> |
| | | 43 | | public static IRuleBuilderOptions<T, string> IsNullableMobileNumber< T >( this IRuleBuilder<T, string> ruleBuilder, |
| | 15 | 44 | | => ruleBuilder.SetValidator( new NullableMobileNumberValidator<T>( regionCode ) ).WithErrorCode( nameof( IsNulla |
| | | 45 | | |
| | | 46 | | /// <summary>The text must be empty or a valid number for the region <paramref name="regionCodeFunc"/> returns.</sum |
| | | 47 | | /// <typeparam name="T">The validated type.</typeparam> |
| | | 48 | | /// <param name="ruleBuilder">The rule builder.</param> |
| | | 49 | | /// <param name="regionCodeFunc">Returns the ISO 3166 region for the instance.</param> |
| | | 50 | | /// <returns>The rule builder options.</returns> |
| | | 51 | | public static IRuleBuilderOptions<T, string> IsNullableMobileNumber< T >( this IRuleBuilder<T, string> ruleBuilder, |
| | 3 | 52 | | => ruleBuilder.SetValidator( new NullableMobileNumberValidator<T>( regionCodeFunc ) ).WithErrorCode( nameof( IsN |
| | | 53 | | } |