PHP code example of jinjie / silverstripe-valitron
1. Go to this page and download the library: Download jinjie/silverstripe-valitron 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/ */
jinjie / silverstripe-valitron example snippets
use SilverStripe\ORM\DataObject;
use SwiftDevLabs\Valitron\Helper;
class MyDataObject extends DataObject {
// Validates DataObject
public function validate()
{
$result = parent::validate();
$v = new \Valitron\Validator([
'Field1' => $this->Field1,
'Field2' => $this->Field2,
]);
// Find more rules at https://github.com/vlucas/valitron
$v->rule('