1. Go to this page and download the library: Download clarkf/simply-valid 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/ */
clarkf / simply-valid example snippets
class MyModel extends SimplyValid\Model
{
protected $rules = array(
// validation rules here
);
}
public function store()
{
$model = new MyModel(Input::get());
if ($model->save()) {
// Model is valid, and has been saved!
} else {
// Handle validation problems here
}
}
class MyModel extends Eloquent
{
public $rules = array(
// Validator rules here
);
public static function boot()
{
parent::boot();
static::observe(new SimplyValid\ValidityObserver());
}
}
public static function boot()
{
parent::boot();
// ...
static::registerModelEvent('errors', function (MyModel $model, MessageBag $errors) {
// Store the errors somewhere useful, for example
$model->errors = $errors;
});
}
class User extends SimplyValid\Model
{
public function getValidationRules()
{
$rules = array();
if (!$this->exists) {
// User has not yet been created, so a password is
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.