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
-
Recent Posts
Tags
.NET Apple ASP.NET AT&T Boo Books C# Castle CodeVoyeur Databases DLR Eclipse employment Google Hosting iPhone IronPython IronRuby JavaScript LINQ LongTailVideo Mac MapReduce mercurial MobileMe MongoDB MonoRail MVC MySQL NAnt NoRM NoSQL Open Source orchard PHP Presenting Python Ruby simplegeo Subversion Teaching Vista Windows Windows 7 WordPressBlogroll
Links
Archives
- March 2012
- December 2011
- November 2011
- August 2011
- May 2011
- March 2011
- February 2011
- November 2010
- October 2010
- August 2010
- July 2010
- June 2010
- May 2010
- March 2010
- October 2009
- September 2009
- June 2009
- April 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
How can we add validation for datatime. There is no option, can we have source code for Python Engine.
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