Class PhoneNumberAttribute
- Namespace
- HeroKit.Validation
- Assembly
- HeroKit.dll
Validates a phone number of a country, for example [PhoneNumber("TR")].
[AttributeUsage(AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Parameter, AllowMultiple = false)]
public sealed class PhoneNumberAttribute : CountryValidationAttribute
- Inheritance
-
PhoneNumberAttribute
- Inherited Members
- Extension Methods
Constructors
PhoneNumberAttribute(string)
Validates a phone number of a country, for example [PhoneNumber("TR")].
public PhoneNumberAttribute(string countryCode)
Parameters
countryCodestringThe ISO 3166-1 alpha-2 code.
Properties
MobileOnly
Gets or sets whether only mobile numbers are accepted.
public bool MobileOnly { get; set; }
Property Value
Methods
IsValid(string, Country)
Validates a non-empty string with the rules of the country.
protected override bool IsValid(string value, Country country)
Parameters
Returns
- bool
True if valid; otherwise false.