Mercurial > pub > bltoolkit
comparison Source/Validation/RequiredAttribute.cs @ 0:f990fcb411a9
Копия текущей версии из github
author | cin |
---|---|
date | Thu, 27 Mar 2014 21:46:09 +0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f990fcb411a9 |
---|---|
1 using System; | |
2 | |
3 namespace BLToolkit.Validation | |
4 { | |
5 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] | |
6 public class RequiredAttribute : ValidatorBaseAttribute | |
7 { | |
8 public RequiredAttribute() | |
9 { | |
10 } | |
11 | |
12 public RequiredAttribute(string errorMessage) | |
13 : base(errorMessage) | |
14 { | |
15 } | |
16 | |
17 public override bool IsValid(ValidationContext context) | |
18 { | |
19 return context.IsNull(context) == false; | |
20 } | |
21 | |
22 public override string ErrorMessage | |
23 { | |
24 get { return base.ErrorMessage ?? "'{0}' is required."; } | |
25 set { base.ErrorMessage = value; } | |
26 } | |
27 } | |
28 } |