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