Argument validation framework released


I’ve finally got my thumb out and cleaned up and made a mini framework of the fluent argument validation concept I blogged about in my last post:

The framework contains a little bit of everything.

Fluent Argument Validation Specification.
An extensible argument validation system based on a fluent extension method API.
(Maybe I should work at marketing ;-) )

Async fork.
A fluent API for performing async operations.

Text parser.
A Deterministic Finite-State Automata based parser.
It is the same parser that we used in NPath for NPersist but with a cleaned up API.

A handful of useful extension methods to increase expressiveness.
Loggers, casting, formatting etc.

Generic Math.
A generic numeric type that supports math operations.



Validation pre conditions:

static string ValidationFunc(int a,string b,DateTime c)
  //pre conditions:


   .IsInRange(new DateTime(2000, 01, 01),
   new DateTime(2010, 01, 01));

Validation post conditions:

string res = "Foo";
//post condition:
return res.Require("res")

Async fork:

static int ForkIt()
   int a = 0;
   int b = 0;

   //begin async fork
       .Call(() => a = SomeSlowCall())
       .Call(() => b = SomeOtherSlowCall())
   //async fork done
   return a + b;


//fluent casts, no need to wrap in ((int)var).

//formatting and output;
myVar.FormatAs("myVar is: {0}").Output();

"Hello {0} {1}".FormatWith(firstName,LastName).Output();

"ROGER ALSING".ToProperCase().Output();

//string matching
bool match = myString.Like("Roger%");
bool match = myString.Match(regexPattern);

 More examples can be found in the demo project and in the unit tests in the same zip as the framework. 




  1. Hi Roger

    Nice work. I actually began messing about making my own framework based on your idea, never got anything finished though.

    How do the “Fork Async” feature work? Do it call the different validations on their own thread and wait till all of them finishes?

  2. Hi Roger,

    Like Egil, I started building my own framework based on your idea. Hopefully, I’ll be able to publish it on CodePlex in a couple of days. You can read more about it on my blog.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s