Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ IsValid() [1/2]

override bool System.ComponentModel.DataAnnotations.PhoneAttribute.IsValid ( object? value)
inlinevirtual

Reimplemented from System.ComponentModel.DataAnnotations.DataTypeAttribute.

Definition at line 12 of file PhoneAttribute.cs.

13 {
14 if (value == null)
15 {
16 return true;
17 }
18 if (!(value is string text))
19 {
20 return false;
21 }
22 string potentialPhoneNumber = text.Replace("+", string.Empty).TrimEnd();
23 potentialPhoneNumber = RemoveExtension(potentialPhoneNumber);
24 bool flag = false;
25 string text2 = potentialPhoneNumber;
26 foreach (char c in text2)
27 {
28 if (char.IsDigit(c))
29 {
30 flag = true;
31 break;
32 }
33 }
34 if (!flag)
35 {
36 return false;
37 }
38 string text3 = potentialPhoneNumber;
39 foreach (char c2 in text3)
40 {
41 if (!char.IsDigit(c2) && !char.IsWhiteSpace(c2) && "-.()".IndexOf(c2) == -1)
42 {
43 return false;
44 }
45 }
46 return true;
47 }
static string RemoveExtension(string potentialPhoneNumber)

References System.ComponentModel.DataAnnotations.PhoneAttribute.RemoveExtension(), System.text, and System.value.