X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fascertain;a=blobdiff_plain;f=README.md;fp=README.md;h=8a75e67e4cd22efece09cdbf6bf2505083fc4ddb;hp=0000000000000000000000000000000000000000;hb=10c3f634f5fc45dd6bc5fe48c6f772d1df927aa6;hpb=0595586942a01f4848a7922a24adf6cbb7a79066 diff --git a/README.md b/README.md new file mode 100644 index 0000000..8a75e67 --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +ascertain +========= + +Harmless validation. + +```php +$user->assert() + ->that("name") + ->isNotNothing("a name is required") + ->isLen(4, "must be at least 4 characters long") + ->that("email") + ->isEmail("is not valid") + ->that("homepage") + ->when($user->hasHomepage()) + ->isUrl("seems not to be a valid URL"); + +# ... + +class User implements \ascertain\Testable +{ + use \ascertain\Validator; + + protected $id; + protected $name; + protected $email; + protected $homepage; + + function hasHomepage() { + return isset($this->homepage); + } + + function export() { + return array( + "name" => $this->name, + "email" => $this->email, + "homepage" => $this->homepage. + ); + } +} +``` +