| | | 1 | | // ReSharper disable once CheckNamespace |
| | | 2 | | namespace FluentValidation; |
| | | 3 | | |
| | | 4 | | /// <summary>Rules on which characters a text may contain.</summary> |
| | | 5 | | public static class FluentValidationStringHelpers |
| | | 6 | | { |
| | | 7 | | /// <summary>Arabic letters, digits, space and <c>| / & - _</c> only.</summary> |
| | | 8 | | /// <typeparam name="T">The validated type.</typeparam> |
| | | 9 | | /// <param name="ruleBuilder">The rule builder.</param> |
| | | 10 | | /// <returns>The rule builder options.</returns> |
| | | 11 | | public static IRuleBuilderOptions<T, string> IsArabicCharsAndSpecialCharactersOnly< T >( this IRuleBuilder<T, string |
| | 18 | 12 | | => ruleBuilder.Matches( @"^[\u0600-\u06FF0-9|/&\-_ ]+$" ).WithErrorCode( nameof( IsArabicCharsAndSpecialCharacte |
| | | 13 | | |
| | | 14 | | /// <summary>Arabic letters, digits and space only.</summary> |
| | | 15 | | /// <typeparam name="T">The validated type.</typeparam> |
| | | 16 | | /// <param name="ruleBuilder">The rule builder.</param> |
| | | 17 | | /// <returns>The rule builder options.</returns> |
| | 9 | 18 | | public static IRuleBuilderOptions<T, string> IsArabicCharsOnly< T >( this IRuleBuilder<T, string> ruleBuilder ) => r |
| | | 19 | | |
| | | 20 | | /// <summary>English letters, digits, space and <c>| / ' & - _</c> only.</summary> |
| | | 21 | | /// <typeparam name="T">The validated type.</typeparam> |
| | | 22 | | /// <param name="ruleBuilder">The rule builder.</param> |
| | | 23 | | /// <returns>The rule builder options.</returns> |
| | | 24 | | public static IRuleBuilderOptions<T, string> IsEnglishCharsNumbersAndSpecialCharactersOnly< T >( this IRuleBuilder<T |
| | 15 | 25 | | => ruleBuilder.Matches( @"^[0-9|/'&\-_ a-zA-Z]+$" ).WithErrorCode( nameof( IsEnglishCharsNumbersAndSpecialCharac |
| | | 26 | | |
| | | 27 | | /// <summary>English letters, digits and space only.</summary> |
| | | 28 | | /// <typeparam name="T">The validated type.</typeparam> |
| | | 29 | | /// <param name="ruleBuilder">The rule builder.</param> |
| | | 30 | | /// <returns>The rule builder options.</returns> |
| | 3 | 31 | | public static IRuleBuilderOptions<T, string> IsEnglishCharsNumbersOnly< T >( this IRuleBuilder<T, string> ruleBuilde |
| | | 32 | | |
| | | 33 | | /// <summary>English letters, space, <c>-</c> and <c>'</c> only (empty allowed).</summary> |
| | | 34 | | /// <typeparam name="T">The validated type.</typeparam> |
| | | 35 | | /// <param name="ruleBuilder">The rule builder.</param> |
| | | 36 | | /// <returns>The rule builder options.</returns> |
| | 3 | 37 | | public static IRuleBuilderOptions<T, string> IsEnglishCharsOnly< T >( this IRuleBuilder<T, string> ruleBuilder ) => |
| | | 38 | | |
| | | 39 | | /// <summary>A hex colour: <c>#RGB</c>, <c>#RRGGBB</c> or <c>#RRGGBBAA</c> (<c>#</c> optional).</summary> |
| | | 40 | | /// <typeparam name="T">The validated type.</typeparam> |
| | | 41 | | /// <param name="ruleBuilder">The rule builder.</param> |
| | | 42 | | /// <returns>The rule builder options.</returns> |
| | 12 | 43 | | public static IRuleBuilderOptions<T, string> IsValidHexColor< T >( this IRuleBuilder<T, string> ruleBuilder ) => rul |
| | | 44 | | } |