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

This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

2 Responses to On a Simple IronPython Validation Framework

  1. Zahid Rasool says:

    How can we add validation for datatime. There is no option, can we have source code for Python Engine.

  2. 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

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">