travis
[m6w6/ascertain] / README.md
1 ascertain
2 =========
3
4 Harmless validation. [![Build Status](https://api.travis-ci.org/mike-php-net/ascertain.png)](https://travis-ci.org/mike-php-net/ascertain)
5
6 ```php
7 $user->assert()
8 ->that("name")
9 ->isNotNothing("a name is required")
10 ->isLen(4, "must be at least 4 characters long")
11 ->that("email")
12 ->isEmail("is not valid")
13 ->that("homepage")
14 ->when($user->hasHomepage())
15 ->isUrl("seems not to be a valid URL");
16
17 # ...
18
19 class User implements \ascertain\Testable
20 {
21 use \ascertain\Validator;
22
23 protected $id;
24 protected $name;
25 protected $email;
26 protected $homepage;
27
28 function hasHomepage() {
29 return isset($this->homepage);
30 }
31
32 function export() {
33 return array(
34 "name" => $this->name,
35 "email" => $this->email,
36 "homepage" => $this->homepage.
37 );
38 }
39 }
40 ```
41