On a Simple IronPython Validation Framework
I do try to keep the content between Code Voyeur and dll Hell distinct. OK, there’s not much content on either… But I think my latest (up to 4!, that’s 4 not 4 factorial) article on Code Voyeur is a pretty neat idea. Shameless cross-promotion link below:
A Simple IronPython Business Object Validation Framework
RSS feed for comments on this post. | TrackBack URI
June 11th, 2008 at 6:51 am
How can we add validation for datatime. There is no option, can we have source code for Python Engine.
June 11th, 2008 at 10:18 pm
Hi Zahid,
The PythonEngine is part of IronPython. You can download that at http://www.codeplex.com/IronPython/.
I’m not sure if this is what you were looking for, but I added a sample to the validation project that adds a DateTime property to the User class. The updated code is at http://code.google.com/p/codevoyeur-samples/.
The new property, Birthday, is a DateTime with a new Validation attribute.
[Validation("is_valid_birthdate")]
public DateTime Birthday { get; set; }
The validation rule simply checks whether the property value for Birthday is a date prior to now.
<rule name="is_valid_birthdate" message="Birthday must be a date prior to today">
result = property_value.CompareTo(DateTime.Now) == -1
</rule>
– John