Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/m6w6/ascertain
Simple validator, not doing much harm
https://github.com/m6w6/ascertain
Last synced: 2 days ago
JSON representation
Simple validator, not doing much harm
- Host: GitHub
- URL: https://github.com/m6w6/ascertain
- Owner: m6w6
- License: bsd-2-clause
- Created: 2013-02-19T11:26:07.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-10-22T07:30:13.000Z (about 11 years ago)
- Last Synced: 2025-01-03T13:12:01.853Z (5 days ago)
- Language: PHP
- Size: 141 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
ascertain
=========
[![Build Status](https://travis-ci.org/mike-php-net/ascertain.png?branch=master)](https://travis-ci.org/mike-php-net/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.
);
}
}
```