Theme Graphic
Theme Graphic

$jonathan.ramble(topic => 'work' & 'play');

My random-ish ramblings about my work at Programmer's Heaven and on the Parrot project, my crazy conference schedule and whatever else I...

Subscribe

Author

I wrote my first computer program when I was 8 years old, and I haven't bothered to stop since! I graduated from the University Of Cambridge, England, in June 2006 having read Computer Science at Emmanuel College. Currently I'm doing consultancy work, a lot of it for this very site. I'm into a whole range of music, including metal, trance, old skool, and industrial. I'm a Christian and have previously been involved in youth and children's work with what was then my local church.

Archive

Tags

Posted on Thursday, May 07, 2009 at 3:50 AM

Open Source Fluent Validation For .Net

I've been working on open source projects for a while, namely Parrot and Perl 6. Recently I've also been hacking on TNValidate, a fluent validation library for .Net. To quote a little code from its synopsis:
// Instantiate validator.
var Validate = new Validator(ValidationLanguageEnum.English);

// Chain rules; automated error generation.
Validate.That(Name, "Name").IsLongerThan(3).IsShorterThan(100);

// Supply a custom error message.
Validate.That(Age, "Age").IsGreaterThanOrEqual(13,
    "You must be older than 13 to sign up");

// Check if validation suceeded.
if (Validate.HasErrors())
{
    // Here you can data-bind the errors, e.g. to a Repeater
    // in ASP.NET.
    ErrorList.DataSource = Validate.ValidatorResults;
    ErrorList.DataBind();
}
else
{
    // Was fine, continue...
    // ...
}
...
Comments: 2 Tags: .NET, C#, Validation

 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.