PHP code example of phpatom / validation
1. Go to this page and download the library: Download phpatom/validation library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phpatom / validation example snippets
$v = new \Atom\Validation\Validator();
$v->assert("title")->is()->present()->filled()->alphaNumeric()->between(10,255);
$v->assert("post_id")->onQueryParams()->is()->present()->filled()->and()->follows(new PostExistenceConstraint());
$v->assert("content")->is()->presentAndFilled();
$v->assert("featured_image")->on(\Atom\Validation\Scope::files())->is()->present()->file()->image()->lessThan(200000);
$v->assert("created_at")->is()->present()->filled()->date()->and()->before("now");
$v->validate($request); // throw ValidationException
//OR
$v->check($request);
if($v->failed()){
return $v->errors();
}