1: [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)]
2: public class RequiredAttribute : ExtendedValidationAttribute
3: {
4: public bool AllowEmptyStrings { get; set; }
5: public RequiredAttribute(string messageId, params object[] args) :
6: base(messageId,args)
7: {}
8: public override bool IsValid(object value)
9: {
10: return new System.ComponentModel.DataAnnotations.RequiredAttribute {AllowEmptyStrings = this.AllowEmptyStrings }.IsValid(value);
11: }
12: }
13:
14: [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)]
15: public class RangeAttribute : ExtendedValidationAttribute
16: {
17: private System.ComponentModel.DataAnnotations.RangeAttribute innerRangeAttribute;
18:
19: public RangeAttribute(double minimum, double maximum, string messageId, params object[] args) :
20: base(messageId, args)
21: {
22: innerRangeAttribute = new System.ComponentModel.DataAnnotations.RangeAttribute(minimum, maximum);
23: }
24:
25: public RangeAttribute(int minimum, int maximum, string messageId, params object[] args):
26: base(messageId, args)
27: {
28: innerRangeAttribute = new System.ComponentModel.DataAnnotations.RangeAttribute(minimum, maximum);
29: }
30:
31: public RangeAttribute(Type type, string minimum, string maximum,string messageId, params object[] args) :
32: base(messageId, args)
33: {
34: innerRangeAttribute = new System.ComponentModel.DataAnnotations.RangeAttribute(type, minimum, maximum);
35: }
36:
37: public override bool IsValid(object value)
38: {
39: return innerRangeAttribute.IsValid(value);
40: }
41: }