CSLA.NET 5.4.2
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
Csla.Validation.Shared/CommonRules.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="CommonRules.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Provides the Common rules for CSLA 3.x</summary>
7//-----------------------------------------------------------------------
8using System;
9using Csla.Properties;
10using System.Text.RegularExpressions;
11using System.Reflection;
12using Csla.Core;
13#if NETFX_CORE
14using Csla.Reflection;
15#endif
16using Csla.Rules;
17
18namespace Csla.Validation
19{
23 public static partial class CommonRules
24 {
25
26 #region StringRequired
27
40 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")]
41 public static bool StringRequired(object target, RuleArgs e)
42 {
43 string value = (string)Utilities.CallByName(
44 target, e.PropertyName, CallType.Get);
45 if (string.IsNullOrEmpty(value))
46 {
47 e.Description = string.Format(Resources.StringRequiredRule, RuleArgs.GetPropertyName(e));
48 return false;
49 }
50 return true;
51 }
52
53 #endregion
54
55 #region StringMaxLength
56
69 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")]
70 public static bool StringMaxLength(
71 object target, RuleArgs e)
72 {
73 DecoratedRuleArgs args = (DecoratedRuleArgs)e;
74 int max = (int)args["MaxLength"];
75 string value = (string)Utilities.CallByName(
76 target, e.PropertyName, CallType.Get);
77 if (!String.IsNullOrEmpty(value) && (value.Length > max))
78 {
79 string format = (string)args["Format"];
80 string outValue;
81 if (string.IsNullOrEmpty(format))
82 outValue = max.ToString();
83 else
84 outValue = max.ToString(format);
85 e.Description = String.Format(
87 RuleArgs.GetPropertyName(e), outValue);
88 return false;
89 }
90 return true;
91 }
92
98 {
102 public int MaxLength
103 {
104 get { return (int)this["MaxLength"]; }
105 }
106
113 string propertyName, int maxLength)
114 : base(propertyName)
115 {
116 this["MaxLength"] = maxLength;
117 this["Format"] = string.Empty;
118 }
119
125 public MaxLengthRuleArgs(Core.IPropertyInfo propertyInfo, int maxLength)
126 : base(propertyInfo)
127 {
128 this["MaxLength"] = maxLength;
129 this["Format"] = string.Empty;
130 }
131
141 string propertyName, string friendlyName, int maxLength)
142 : base(propertyName, friendlyName)
143 {
144 this["MaxLength"] = maxLength;
145 this["Format"] = string.Empty;
146 }
147
156 string propertyName, int maxLength, string format)
157 : base(propertyName)
158 {
159 this["MaxLength"] = maxLength;
160 this["Format"] = format;
161 }
162
170 public MaxLengthRuleArgs(Core.IPropertyInfo propertyInfo, int maxLength, string format)
171 : base(propertyInfo)
172 {
173 this["MaxLength"] = maxLength;
174 this["Format"] = format;
175 }
176
188 string propertyName, string friendlyName, int maxLength, string format)
189 : base(propertyName, friendlyName)
190 {
191 this["MaxLength"] = maxLength;
192 this["Format"] = format;
193 }
194 }
195
196 #endregion
197
198 #region StringMinLength
199
212 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")]
213 public static bool StringMinLength(
214 object target, RuleArgs e)
215 {
217 int min = (int)args["MinLength"];
218 string value = (string)Utilities.CallByName(
219 target, e.PropertyName, CallType.Get);
220 if (String.IsNullOrEmpty(value) || (value.Length < min))
221 {
222 string format = (string)args["Format"];
223 string outValue;
224 if (string.IsNullOrEmpty(format))
225 outValue = min.ToString();
226 else
227 outValue = min.ToString(format);
228 e.Description = String.Format(
230 RuleArgs.GetPropertyName(e), outValue);
231 return false;
232 }
233 return true;
234 }
235
241 {
245 public int MinLength
246 {
247 get { return (int)this["MinLength"]; }
248 }
249
256 string propertyName, int minLength)
257 : base(propertyName)
258 {
259 this["MinLength"] = minLength;
260 this["Format"] = string.Empty;
261 }
262
269 Core.IPropertyInfo propertyInfo, int minLength)
270 : base(propertyInfo)
271 {
272 this["MinLength"] = minLength;
273 this["Format"] = string.Empty;
274 }
275
285 string propertyName, string friendlyName, int minLength)
286 : base(propertyName, friendlyName)
287 {
288 this["MinLength"] = minLength;
289 this["Format"] = string.Empty;
290 }
291
300 string propertyName, int minLength, string format)
301 : base(propertyName)
302 {
303 this["MinLength"] = minLength;
304 this["Format"] = format;
305 }
306
315 Core.IPropertyInfo propertyInfo, int minLength, string format)
316 : base(propertyInfo)
317 {
318 this["MinLength"] = minLength;
319 this["Format"] = format;
320 }
321
333 string propertyName, string friendlyName, int minLength, string format)
334 : base(propertyName, friendlyName)
335 {
336 this["MinLength"] = minLength;
337 this["Format"] = format;
338 }
339 }
340
341 #endregion
342
343 #region IntegerMaxValue
344
353 public static bool IntegerMaxValue(object target, RuleArgs e)
354 {
356 int max = (int)args["MaxValue"];
357 int value = (int)Utilities.CallByName(target, e.PropertyName, CallType.Get);
358 if (value > max)
359 {
360 string format = (string)args["Format"];
361 string outValue;
362 if (string.IsNullOrEmpty(format))
363 outValue = max.ToString();
364 else
365 outValue = max.ToString(format);
366 e.Description = String.Format(Resources.MaxValueRule,
367 RuleArgs.GetPropertyName(e), outValue);
368 return false;
369 }
370 return true;
371 }
372
378 {
382 public int MaxValue
383 {
384 get { return (int)this["MaxValue"]; }
385 }
386
392 public IntegerMaxValueRuleArgs(string propertyName, int maxValue)
393 : base(propertyName)
394 {
395 this["MaxValue"] = maxValue;
396 this["Format"] = string.Empty;
397 }
398
404 public IntegerMaxValueRuleArgs(Core.IPropertyInfo propertyInfo, int maxValue)
405 : base(propertyInfo)
406 {
407 this["MaxValue"] = maxValue;
408 this["Format"] = string.Empty;
409 }
410
420 string propertyName, string friendlyName, int maxValue)
421 : base(propertyName, friendlyName)
422 {
423 this["MaxValue"] = maxValue;
424 this["Format"] = string.Empty;
425 }
426
434 public IntegerMaxValueRuleArgs(string propertyName, int maxValue, string format)
435 : base(propertyName)
436 {
437 this["MaxValue"] = maxValue;
438 this["Format"] = format;
439 }
440
448 public IntegerMaxValueRuleArgs(Core.IPropertyInfo propertyInfo, int maxValue, string format)
449 : base(propertyInfo)
450 {
451 this["MaxValue"] = maxValue;
452 this["Format"] = format;
453 }
454
466 string propertyName, string friendlyName, int maxValue, string format)
467 : base(propertyName, friendlyName)
468 {
469 this["MaxValue"] = maxValue;
470 this["Format"] = format;
471 }
472 }
473
474 #endregion
475
476 #region IntegerMinValue
477
486 public static bool IntegerMinValue(object target, RuleArgs e)
487 {
489 int min = (int)args["MinValue"];
490 int value = (int)Utilities.CallByName(target, e.PropertyName, CallType.Get);
491 if (value < min)
492 {
493 string format = (string)args["Format"];
494 string outValue;
495 if (string.IsNullOrEmpty(format))
496 outValue = min.ToString();
497 else
498 outValue = min.ToString(format);
499 e.Description = String.Format(Resources.MinValueRule,
500 RuleArgs.GetPropertyName(e), outValue);
501 return false;
502 }
503 return true;
504 }
505
511 {
515 public int MinValue
516 {
517 get { return (int)this["MinValue"]; }
518 }
519
525 public IntegerMinValueRuleArgs(string propertyName, int minValue)
526 : base(propertyName)
527 {
528 this["MinValue"] = minValue;
529 this["Format"] = string.Empty;
530 }
531
537 public IntegerMinValueRuleArgs(Core.IPropertyInfo propertyInfo, int minValue)
538 : base(propertyInfo)
539 {
540 this["MinValue"] = minValue;
541 this["Format"] = string.Empty;
542 }
543
553 string propertyName, string friendlyName, int minValue)
554 : base(propertyName, friendlyName)
555 {
556 this["MinValue"] = minValue;
557 this["Format"] = string.Empty;
558 }
559
567 public IntegerMinValueRuleArgs(string propertyName, int minValue, string format)
568 : base(propertyName)
569 {
570 this["MinValue"] = minValue;
571 this["Format"] = format;
572 }
573
581 public IntegerMinValueRuleArgs(Core.IPropertyInfo propertyInfo, int minValue, string format)
582 : base(propertyInfo)
583 {
584 this["MinValue"] = minValue;
585 this["Format"] = format;
586 }
587
599 string propertyName, string friendlyName, int minValue, string format)
600 : base(propertyName, friendlyName)
601 {
602 this["MinValue"] = minValue;
603 this["Format"] = format;
604 }
605 }
606
607 #endregion
608
609 #region MaxValue
610
620 public static bool MaxValue<T>(object target, RuleArgs e) where T : IComparable
621 {
623 PropertyInfo pi = target.GetType().GetProperty(e.PropertyName);
624 T value = (T)pi.GetValue(target, null);
625 T max = (T)args["MaxValue"];
626
627 int result = value.CompareTo(max);
628 if (result >= 1)
629 {
630 string format = (string)args["Format"];
631 string outValue;
632 if (string.IsNullOrEmpty(format))
633 outValue = max.ToString();
634 else
635 outValue = string.Format(string.Format("{{0:{0}}}", format), max);
636 e.Description = string.Format(Resources.MaxValueRule,
637 RuleArgs.GetPropertyName(e), outValue);
638 return false;
639 }
640 else
641 return true;
642 }
643
650 {
654 public T MaxValue
655 {
656 get { return (T)this["MaxValue"]; }
657 }
658
664 public MaxValueRuleArgs(string propertyName, T maxValue)
665 : base(propertyName)
666 {
667 this["MaxValue"] = maxValue;
668 this["Format"] = string.Empty;
669 this["ValueType"] = typeof(T).FullName;
670 }
671
677 public MaxValueRuleArgs(Core.IPropertyInfo propertyInfo, T maxValue)
678 : base(propertyInfo)
679 {
680 this["MaxValue"] = maxValue;
681 this["Format"] = string.Empty;
682 this["ValueType"] = typeof(T).FullName;
683 }
684
694 string propertyName, string friendlyName, T maxValue)
695 : base(propertyName, friendlyName)
696 {
697 this["MaxValue"] = maxValue;
698 this["Format"] = string.Empty;
699 this["ValueType"] = typeof(T).FullName;
700 }
701
709 public MaxValueRuleArgs(string propertyName, T maxValue, string format)
710 : base(propertyName)
711 {
712 this["MaxValue"] = maxValue;
713 this["Format"] = format;
714 this["ValueType"] = typeof(T).FullName;
715 }
716
724 public MaxValueRuleArgs(Core.IPropertyInfo propertyInfo, T maxValue, string format)
725 : base(propertyInfo)
726 {
727 this["MaxValue"] = maxValue;
728 this["Format"] = format;
729 this["ValueType"] = typeof(T).FullName;
730 }
731
743 string propertyName, string friendlyName, T maxValue, string format)
744 : base(propertyName, friendlyName)
745 {
746 this["MaxValue"] = maxValue;
747 this["Format"] = format;
748 this["ValueType"] = typeof(T).FullName;
749 }
750 }
751
752 #endregion
753
754 #region MinValue
755
765 public static bool MinValue<T>(object target, RuleArgs e) where T : IComparable
766 {
768 PropertyInfo pi = target.GetType().GetProperty(e.PropertyName);
769 T value = (T)pi.GetValue(target, null);
770 T min = (T)args["MinValue"];
771
772 int result = value.CompareTo(min);
773 if (result <= -1)
774 {
775 string format = (string)args["Format"];
776 string outValue;
777 if (string.IsNullOrEmpty(format))
778 outValue = min.ToString();
779 else
780 outValue = string.Format(string.Format("{{0:{0}}}", format), min);
781 e.Description = string.Format(Resources.MinValueRule,
782 RuleArgs.GetPropertyName(e), outValue);
783 return false;
784 }
785 else
786 return true;
787 }
788
795 {
799 public T MinValue
800 {
801 get { return (T)this["MinValue"]; }
802 }
803
809 public MinValueRuleArgs(string propertyName, T minValue)
810 : base(propertyName)
811 {
812 this["MinValue"] = minValue;
813 this["Format"] = string.Empty;
814 this["ValueType"] = typeof(T).FullName;
815 }
816
822 public MinValueRuleArgs(Core.IPropertyInfo propertyInfo, T minValue)
823 : base(propertyInfo)
824 {
825 this["MinValue"] = minValue;
826 this["Format"] = string.Empty;
827 this["ValueType"] = typeof(T).FullName;
828 }
829
839 string propertyName, string friendlyName, T minValue)
840 : base(propertyName, friendlyName)
841 {
842 this["MinValue"] = minValue;
843 this["Format"] = string.Empty;
844 this["ValueType"] = typeof(T).FullName;
845 }
846
854 public MinValueRuleArgs(string propertyName, T minValue, string format)
855 : base(propertyName)
856 {
857 this["MinValue"] = minValue;
858 this["Format"] = format;
859 this["ValueType"] = typeof(T).FullName;
860 }
861
869 public MinValueRuleArgs(Core.IPropertyInfo propertyInfo, T minValue, string format)
870 : base(propertyInfo)
871 {
872 this["MinValue"] = minValue;
873 this["Format"] = format;
874 this["ValueType"] = typeof(T).FullName;
875 }
876
888 string propertyName, string friendlyName, T minValue, string format)
889 : base(propertyName, friendlyName)
890 {
891 this["MinValue"] = minValue;
892 this["Format"] = format;
893 this["ValueType"] = typeof(T).FullName;
894 }
895 }
896
897 #endregion
898
899 #region RegEx
900
912 public static bool RegExMatch(object target, RuleArgs e)
913 {
914 bool ruleSatisfied = false;
916 RegExRuleArgs.NullResultOptions nullOption =
917 (RegExRuleArgs.NullResultOptions)args["NullOption"];
918 Regex expression = (Regex)args["RegEx"];
919
920 object value = Utilities.CallByName(target, e.PropertyName, CallType.Get);
921 if (value == null && nullOption == RegExRuleArgs.NullResultOptions.ConvertToEmptyString)
922 value = string.Empty;
923
924 if (value == null)
925 {
926 // if the value is null at this point
927 // then return the pre-defined result value
928 ruleSatisfied = (nullOption == RegExRuleArgs.NullResultOptions.ReturnTrue);
929 }
930 else
931 {
932 // the value is not null, so run the
933 // regular expression
934 ruleSatisfied = expression.IsMatch(value.ToString());
935 }
936
937 if (!ruleSatisfied)
938 {
939 e.Description = String.Format(Resources.RegExMatchRule, RuleArgs.GetPropertyName(e));
940 return false;
941 }
942 else
943 return true;
944 }
945
949 public enum RegExPatterns
950 {
954 SSN,
958 Email
959 }
960
966 {
967 #region NullResultOptions
968
974 {
980 ReturnFalse,
986 ReturnTrue,
994 ConvertToEmptyString
995 }
996
997 #endregion
998
1003 public Regex RegEx
1004 {
1005 get { return (Regex)this["RegEx"]; }
1006 }
1007
1013 {
1014 get
1015 {
1016 return (NullResultOptions)this["NullOption"];
1017 }
1018 }
1019
1025 public RegExRuleArgs(string propertyName, RegExPatterns pattern)
1026 : base(propertyName)
1027 {
1028 this["RegEx"] = new Regex(GetPattern(pattern));
1029 this["NullOption"] = NullResultOptions.ReturnFalse;
1030 }
1031
1037 public RegExRuleArgs(Core.IPropertyInfo propertyInfo, RegExPatterns pattern)
1038 : base(propertyInfo)
1039 {
1040 this["RegEx"] = new Regex(GetPattern(pattern));
1041 this["NullOption"] = NullResultOptions.ReturnFalse;
1042 }
1043
1053 string propertyName, string friendlyName, RegExPatterns pattern)
1054 : base(propertyName, friendlyName)
1055 {
1056 this["RegEx"] = new Regex(GetPattern(pattern));
1057 this["NullOption"] = NullResultOptions.ReturnFalse;
1058 }
1059
1065 public RegExRuleArgs(string propertyName, string pattern)
1066 : base(propertyName)
1067 {
1068 this["RegEx"] = new Regex(pattern);
1069 this["NullOption"] = NullResultOptions.ReturnFalse;
1070 }
1071
1077 public RegExRuleArgs(Core.IPropertyInfo propertyInfo, string pattern)
1078 : base(propertyInfo)
1079 {
1080 this["RegEx"] = new Regex(pattern);
1081 this["NullOption"] = NullResultOptions.ReturnFalse;
1082 }
1083
1093 string propertyName, string friendlyName, string pattern)
1094 : base(propertyName, friendlyName)
1095 {
1096 this["RegEx"] = new Regex(pattern);
1097 this["NullOption"] = NullResultOptions.ReturnFalse;
1098 }
1099
1105 public RegExRuleArgs(string propertyName, System.Text.RegularExpressions.Regex regEx)
1106 : base(propertyName)
1107 {
1108 this["RegEx"] = regEx;
1109 this["NullOption"] = NullResultOptions.ReturnFalse;
1110 }
1111
1117 public RegExRuleArgs(Core.IPropertyInfo propertyInfo, System.Text.RegularExpressions.Regex regEx)
1118 : base(propertyInfo)
1119 {
1120 this["RegEx"] = regEx;
1121 this["NullOption"] = NullResultOptions.ReturnFalse;
1122 }
1123
1133 string propertyName, string friendlyName, System.Text.RegularExpressions.Regex regEx)
1134 : base(propertyName, friendlyName)
1135 {
1136 this["RegEx"] = regEx;
1137 this["NullOption"] = NullResultOptions.ReturnFalse;
1138 }
1139
1149 public RegExRuleArgs(string propertyName, RegExPatterns pattern, NullResultOptions nullResult)
1150 : base(propertyName)
1151 {
1152 this["RegEx"] = new Regex(GetPattern(pattern));
1153 this["NullOption"] = nullResult;
1154 }
1155
1165 public RegExRuleArgs(Core.IPropertyInfo propertyInfo, RegExPatterns pattern, NullResultOptions nullResult)
1166 : base(propertyInfo)
1167 {
1168 this["RegEx"] = new Regex(GetPattern(pattern));
1169 this["NullOption"] = nullResult;
1170 }
1171
1185 string propertyName, string friendlyName, RegExPatterns pattern, NullResultOptions nullResult)
1186 : base(propertyName, friendlyName)
1187 {
1188 this["RegEx"] = new Regex(GetPattern(pattern));
1189 this["NullOption"] = nullResult;
1190 }
1191
1201 public RegExRuleArgs(string propertyName, string pattern, NullResultOptions nullResult)
1202 : base(propertyName)
1203 {
1204 this["RegEx"] = new Regex(pattern);
1205 this["NullOption"] = nullResult;
1206 }
1207
1217 public RegExRuleArgs(Core.IPropertyInfo propertyInfo, string pattern, NullResultOptions nullResult)
1218 : base(propertyInfo)
1219 {
1220 this["RegEx"] = new Regex(pattern);
1221 this["NullOption"] = nullResult;
1222 }
1223
1237 string propertyName, string friendlyName, string pattern, NullResultOptions nullResult)
1238 : base(propertyName, friendlyName)
1239 {
1240 this["RegEx"] = new Regex(pattern);
1241 this["NullOption"] = nullResult;
1242 }
1243
1253 public RegExRuleArgs(string propertyName, System.Text.RegularExpressions.Regex regEx, NullResultOptions nullResult)
1254 : base(propertyName)
1255 {
1256 this["RegEx"] = regEx;
1257 this["NullOption"] = nullResult;
1258 }
1259
1269 public RegExRuleArgs(Core.IPropertyInfo propertyInfo, System.Text.RegularExpressions.Regex regEx, NullResultOptions nullResult)
1270 : base(propertyInfo)
1271 {
1272 this["RegEx"] = regEx;
1273 this["NullOption"] = nullResult;
1274 }
1275
1289 string propertyName, string friendlyName, System.Text.RegularExpressions.Regex regEx, NullResultOptions nullResult)
1290 : base(propertyName, friendlyName)
1291 {
1292 this["RegEx"] = regEx;
1293 this["NullOption"] = nullResult;
1294 }
1295
1300 public static string GetPattern(RegExPatterns pattern)
1301 {
1302 switch (pattern)
1303 {
1304 case RegExPatterns.SSN:
1305 return @"^\d{3}-\d{2}-\d{4}$";
1306 case RegExPatterns.Email:
1307 return @"^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$";
1308 default:
1309 return string.Empty;
1310 }
1311 }
1312 }
1313
1314 #endregion
1315
1316 #region CanRead
1317
1329 public static bool CanRead(object target, RuleArgs e)
1330 {
1331 bool isAuthorized = true;
1332
1333 BusinessBase business = target as BusinessBase;
1334 if (business != null && !string.IsNullOrEmpty(e.PropertyName))
1335 isAuthorized = business.CanReadProperty(e.PropertyName);
1336
1337 if (!isAuthorized)
1338 {
1339 e.Severity = RuleSeverity.Information;
1340 e.Description = string.Format("You are not authorized to read this field {0}", RuleArgs.GetPropertyName(e));
1341 }
1342
1343 return isAuthorized;
1344 }
1345
1346 #endregion
1347
1348 #region CanWrite
1349
1361 public static bool CanWrite(object target, RuleArgs e)
1362 {
1363 bool isAuthorized = true;
1364
1365 BusinessBase business = target as BusinessBase;
1366 if (business != null && !string.IsNullOrEmpty(e.PropertyName))
1367 isAuthorized = business.CanWriteProperty(e.PropertyName);
1368
1369 if (!isAuthorized)
1370 {
1371 e.Severity = RuleSeverity.Information;
1372 e.Description = string.Format("You are not authorized to write to this field {0}", RuleArgs.GetPropertyName(e));
1373 }
1374
1375 return isAuthorized;
1376 }
1377
1378 #endregion
1379
1380 #region DataAnnotations
1381
1387 {
1398 public DataAnnotationRuleArgs(string name, System.ComponentModel.DataAnnotations.ValidationAttribute attribute)
1399 : base(name)
1400 {
1401 Attribute = attribute;
1402 }
1403
1407 public System.ComponentModel.DataAnnotations.ValidationAttribute Attribute { get; set; }
1408
1412 public override string ToString()
1413 {
1414 return string.Format("{0}?Attribute={1}", base.ToString(), Attribute.GetType().FullName);
1415 }
1416 }
1417
1430 public static bool DataAnnotation(object target, RuleArgs e)
1431 {
1432 var args = (DataAnnotationRuleArgs)e;
1433 object pValue = Utilities.CallByName(target, e.PropertyName, CallType.Get);
1434
1435 var ctx = new System.ComponentModel.DataAnnotations.ValidationContext(target, null, null)
1436 {
1437 MemberName = RuleArgs.GetPropertyName(e)
1438 };
1439
1440 var result = args.Attribute.GetValidationResult(pValue, ctx);
1441
1442 if (result != null)
1443 {
1444 e.Description = result.ErrorMessage;
1445 return false;
1446 }
1447
1448 return true;
1449 }
1450
1451 #endregion
1452 }
1453}
This is the non-generic base class from which most business objects will be derived.
virtual bool CanWriteProperty(Csla.Core.IPropertyInfo property)
Returns true if the user is allowed to write the specified property.
virtual bool CanReadProperty(Csla.Core.IPropertyInfo property)
Returns true if the user is allowed to read the calling property.
A strongly-typed resource class, for looking up localized strings, etc.
static string MaxValueRule
Looks up a localized string similar to {0} can not exceed {1}.
static string StringMaxLengthRule
Looks up a localized string similar to {0} can not exceed {1} characters.
static string StringRequiredRule
Looks up a localized string similar to {0} required.
static string MinValueRule
Looks up a localized string similar to {0} can not be less than {1}.
static string RegExMatchRule
Looks up a localized string similar to {0} does not match regular expression.
static string StringMinLengthRule
Looks up a localized string similar to {0} must be at least {1} characters.
Maintains metadata about a property.
Intermediate base class for BusinessBase
Arguments provided to the DataAnnotation rule method
System.ComponentModel.DataAnnotations.ValidationAttribute Attribute
The attribute containing the rule implementation.
override string ToString()
Gets a string representation of the object.
DataAnnotationRuleArgs(string name, System.ComponentModel.DataAnnotations.ValidationAttribute attribute)
Creates an instance of the object.
Custom RuleArgs object required by the IntegerMaxValue rule method.
IntegerMaxValueRuleArgs(string propertyName, int maxValue, string format)
Create a new object.
IntegerMaxValueRuleArgs(string propertyName, string friendlyName, int maxValue)
Create a new object.
IntegerMaxValueRuleArgs(Core.IPropertyInfo propertyInfo, int maxValue, string format)
Create a new object.
IntegerMaxValueRuleArgs(string propertyName, string friendlyName, int maxValue, string format)
Create a new object.
IntegerMaxValueRuleArgs(string propertyName, int maxValue)
Create a new object.
IntegerMaxValueRuleArgs(Core.IPropertyInfo propertyInfo, int maxValue)
Create a new object.
Custom RuleArgs object required by the IntegerMinValue rule method.
IntegerMinValueRuleArgs(string propertyName, string friendlyName, int minValue, string format)
Create a new object.
IntegerMinValueRuleArgs(string propertyName, int minValue, string format)
Create a new object.
IntegerMinValueRuleArgs(Core.IPropertyInfo propertyInfo, int minValue)
Create a new object.
IntegerMinValueRuleArgs(string propertyName, string friendlyName, int minValue)
Create a new object.
IntegerMinValueRuleArgs(Core.IPropertyInfo propertyInfo, int minValue, string format)
Create a new object.
IntegerMinValueRuleArgs(string propertyName, int minValue)
Create a new object.
Custom RuleArgs object required by the StringMaxLength rule method.
MaxLengthRuleArgs(string propertyName, string friendlyName, int maxLength)
Create a new object.
MaxLengthRuleArgs(Core.IPropertyInfo propertyInfo, int maxLength, string format)
Create a new object.
MaxLengthRuleArgs(string propertyName, string friendlyName, int maxLength, string format)
Create a new object.
MaxLengthRuleArgs(string propertyName, int maxLength, string format)
Create a new object.
MaxLengthRuleArgs(Core.IPropertyInfo propertyInfo, int maxLength)
Create a new object.
MaxLengthRuleArgs(string propertyName, int maxLength)
Create a new object.
Custom RuleArgs object required by the MaxValue rule method.
MaxValueRuleArgs(string propertyName, string friendlyName, T maxValue, string format)
Create a new object.
MaxValueRuleArgs(string propertyName, T maxValue, string format)
Create a new object.
MaxValueRuleArgs(string propertyName, T maxValue)
Create a new object.
MaxValueRuleArgs(Core.IPropertyInfo propertyInfo, T maxValue)
Create a new object.
MaxValueRuleArgs(Core.IPropertyInfo propertyInfo, T maxValue, string format)
Create a new object.
MaxValueRuleArgs(string propertyName, string friendlyName, T maxValue)
Create a new object.
Custom RuleArgs object required by the StringMinLength rule method.
MinLengthRuleArgs(Core.IPropertyInfo propertyInfo, int minLength)
Create a new object.
MinLengthRuleArgs(string propertyName, string friendlyName, int minLength)
Create a new object.
MinLengthRuleArgs(string propertyName, int minLength)
Create a new object.
MinLengthRuleArgs(Core.IPropertyInfo propertyInfo, int minLength, string format)
Create a new object.
MinLengthRuleArgs(string propertyName, int minLength, string format)
Create a new object.
MinLengthRuleArgs(string propertyName, string friendlyName, int minLength, string format)
Create a new object.
Custom RuleArgs object required by the MinValue rule method.
MinValueRuleArgs(Core.IPropertyInfo propertyInfo, T minValue, string format)
Create a new object.
MinValueRuleArgs(Core.IPropertyInfo propertyInfo, T minValue)
Create a new object.
MinValueRuleArgs(string propertyName, string friendlyName, T minValue)
Create a new object.
MinValueRuleArgs(string propertyName, T minValue, string format)
Create a new object.
MinValueRuleArgs(string propertyName, string friendlyName, T minValue, string format)
Create a new object.
MinValueRuleArgs(string propertyName, T minValue)
Create a new object.
Custom RuleArgs object required by the RegExMatch rule method.
RegExRuleArgs(string propertyName, string pattern)
Creates a new object.
Regex RegEx
The RegEx object used to validate the property.
RegExRuleArgs(string propertyName, string friendlyName, System.Text.RegularExpressions.Regex regEx, NullResultOptions nullResult)
Creates a new object.
RegExRuleArgs(string propertyName, string friendlyName, RegExPatterns pattern)
Creates a new object.
RegExRuleArgs(string propertyName, string pattern, NullResultOptions nullResult)
Creates a new object.
NullResultOptions
List of options for the NullResult property.
RegExRuleArgs(Core.IPropertyInfo propertyInfo, string pattern)
Creates a new object.
RegExRuleArgs(string propertyName, string friendlyName, string pattern, NullResultOptions nullResult)
Creates a new object.
RegExRuleArgs(string propertyName, string friendlyName, System.Text.RegularExpressions.Regex regEx)
Creates a new object.
RegExRuleArgs(string propertyName, System.Text.RegularExpressions.Regex regEx)
Creates a new object.
NullResultOptions NullResult
Gets a value indicating whether a null value means the rule will return true or false.
RegExRuleArgs(string propertyName, string friendlyName, string pattern)
Creates a new object.
RegExRuleArgs(string propertyName, RegExPatterns pattern)
Creates a new object.
RegExRuleArgs(Core.IPropertyInfo propertyInfo, System.Text.RegularExpressions.Regex regEx)
Creates a new object.
RegExRuleArgs(string propertyName, System.Text.RegularExpressions.Regex regEx, NullResultOptions nullResult)
Creates a new object.
static string GetPattern(RegExPatterns pattern)
Returns the specified built-in regex pattern.
RegExRuleArgs(Core.IPropertyInfo propertyInfo, RegExPatterns pattern, NullResultOptions nullResult)
Creates a new object.
RegExRuleArgs(string propertyName, RegExPatterns pattern, NullResultOptions nullResult)
Creates a new object.
RegExRuleArgs(Core.IPropertyInfo propertyInfo, string pattern, NullResultOptions nullResult)
Creates a new object.
RegExRuleArgs(string propertyName, string friendlyName, RegExPatterns pattern, NullResultOptions nullResult)
Creates a new object.
RegExRuleArgs(Core.IPropertyInfo propertyInfo, RegExPatterns pattern)
Creates a new object.
RegExRuleArgs(Core.IPropertyInfo propertyInfo, System.Text.RegularExpressions.Regex regEx, NullResultOptions nullResult)
Creates a new object.
Object providing extra information to methods that implement business rules.
override string ToString()
Return a string representation of the object using the rule:// URI format.
Object providing extra information to methods that implement business rules.
Definition: RuleArgs.cs:22
string Description
Set by the rule handler method to describe the broken rule.
Definition: RuleArgs.cs:59
RuleSeverity Severity
Gets or sets the severity of the broken rule.
Definition: RuleArgs.cs:75
string PropertyName
The name of the property to be validated.
Definition: RuleArgs.cs:33
static string GetPropertyName(RuleArgs e)
Gets the property name from the RuleArgs object, using the friendly name if one is defined.
Definition: RuleArgs.cs:313
RuleSeverity
Values for validation rule severities.
Definition: RuleSeverity.cs:16
CallType
Valid options for calling a property or method via the Csla.Utilities.CallByName method.
Definition: Utilities.cs:318