Fluent Argument Validation
.NET August 31st, 2008Um bom exemplo de como usar uma fluent interface para fazer validação de pré e pós condições escrito por Roger Alsing.
Ele até empacotou tudo em um “framework”.
E por falar em fluent interfaces, o Guilherme Chapiewski fez dois ótimos posts a alguns meses.
static string ValidationFunc(int a,string b,DateTime c)
{
//pre conditions:
a.Require("a")
.IsGreaterThan(10);
b.Require("b")
.NotNull()
.NotEmpty()
.LongerThan(2)
.StartsWith("Ro");
c.Require("c")
.IsInRange(new DateTime(2000, 01, 01),
new DateTime(2010, 01, 01));




Recent Comments