From d00ba2299d2b4c7ea151197b7e44fcf45bc709da Mon Sep 17 00:00:00 2001 From: Alexandre Gomes Gaigalas Date: Mon, 27 Sep 2010 18:56:34 -0300 Subject: [PATCH] Better samples --- README.textile | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/README.textile b/README.textile index 08192410..1b26c668 100644 --- a/README.textile +++ b/README.textile @@ -4,25 +4,29 @@ Respect\Validation aims to be the most awesome validation toolkit ever created. Here some nice little things you can do using it: -bc.. validate($someNumber); + +h3. Chained validation +bc. //From 1 to 15 non-whitespace alphanumeric characters $username = 'alganet'; $validUsername = v::alnum() ->noWhitespace() ->stringLength(1,15) ->validate($username); +bc. //Date between two ranges using a specific format $someDate = '2010-10-15'; $validDate = v::date('Y-m-d') ->dateBetween('2009-01-01', 2011-01-01') ->validate($someDate); - //Validating objects attributes - $user = new \stdClass; +h3. Validating object attributes +bc..$user = new \stdClass; $user->name = 'Alexandre'; $user->birthdate = '1987-07-01'; @@ -31,13 +35,15 @@ bc.. noWhitespace() )); - //Cool, informative exceptions: - try { +h3. Cool, informative exceptions: +bc.. try { $username = '#$% #odjfubgihdbfgihbdfighb'; $validUsername = v::alnum() ->noWhitespace() @@ -65,10 +71,10 @@ bc.. getMessage(); } - //Non-fluent interface for Dependency Injection maniacs - $validator = new v\Rules\Numeric(); +h3.Non-fluent interface for Dependency Injection maniacs +bc.. $validator = new v\Rules\Numeric(); $validator->validate(123); -.p +.p Cool, isn't it?