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

◆ IsValid() [1/2]

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

Reimplemented from System.ComponentModel.DataAnnotations.ValidationAttribute.

Definition at line 12 of file CreditCardAttribute.cs.

13 {
14 if (value == null)
15 {
16 return true;
17 }
18 if (!(value is string text))
19 {
20 return false;
21 }
22 string text2 = text.Replace("-", string.Empty);
23 text2 = text2.Replace(" ", string.Empty);
24 int num = 0;
25 bool flag = false;
26 for (int num2 = text2.Length - 1; num2 >= 0; num2--)
27 {
28 char c = text2[num2];
29 if (c < '0' || c > '9')
30 {
31 return false;
32 }
33 int num3 = (c - 48) * ((!flag) ? 1 : 2);
34 flag = !flag;
35 while (num3 > 0)
36 {
37 num += num3 % 10;
38 num3 /= 10;
39 }
40 }
41 return num % 10 == 0;
42 }

References System.text, and System.value.