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

◆ IsValid() [1/2]

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

Reimplemented from System.ComponentModel.DataAnnotations.ValidationAttribute.

Definition at line 28 of file MaxLengthAttribute.cs.

29 {
31 if (value == null)
32 {
33 return true;
34 }
35 int num;
36 if (value is string text)
37 {
38 num = text.Length;
39 }
40 else
41 {
42 if (!CountPropertyHelper.TryGetCount(value, out var count))
43 {
44 throw new InvalidCastException(System.SR.Format(System.SR.LengthAttribute_InvalidValueType, value.GetType()));
45 }
46 num = count;
47 }
48 if (-1 != Length)
49 {
50 return num <= Length;
51 }
52 return true;
53 }
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string LengthAttribute_InvalidValueType
Definition SR.cs:68
Definition SR.cs:7

References System.count, System.ComponentModel.DataAnnotations.MaxLengthAttribute.EnsureLegalLengths(), System.SR.Format(), System.ComponentModel.DataAnnotations.MaxLengthAttribute.Length, System.SR.LengthAttribute_InvalidValueType, System.text, System.ComponentModel.DataAnnotations.CountPropertyHelper.TryGetCount(), and System.value.