Class PhoneNumberAttribute
- Namespace
- PhoneNumbers.Extensions
- Assembly
- PhoneNumbers.Extensions.dll
Validates that a property, field, or parameter is a valid phone number, using the same validity check as IsValidNumber(PhoneNumber) rather than a loose format regex. Accepts a string (parsed via Region) or an already-parsed PhoneNumber.
public sealed class PhoneNumberAttribute : ValidationAttribute
- Inheritance
-
PhoneNumberAttribute
- Inherited Members
Constructors
PhoneNumberAttribute()
public PhoneNumberAttribute()
Properties
Region
Default region used to interpret a national-format string, e.g. "US". Not needed for numbers already in E.164 format (leading "+"), or when the value is a PhoneNumber.
public string Region { get; set; }
Property Value
Methods
IsValid(object)
Determines whether the specified value of the object is valid.
public override bool IsValid(object value)
Parameters
valueobjectThe value of the object to validate.
Returns
Exceptions
- InvalidOperationException
The current attribute is malformed.
- NotImplementedException
Neither overload of
IsValidhas been implemented by a derived class.