for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Ajax\semantic\components\validation;
/**
* @author jc
* @version 1.001
* Generates a JSON field validator
*/
class FieldValidation implements \JsonSerializable{
* @var string
protected $identifier;
* @var array array of Rules
protected $rules;
protected $depends;
protected $optional;
public function __construct($identifier){
$this->identifier=$identifier;
$this->rules=[];
}
public function getIdentifier() {
return $this->identifier;
public function setIdentifier($identifier) {
return $this;
public function getRules() {
return $this->rules;
public function addRule($type,$prompt=NULL,$value=NULL){
if($type instanceof Rule)
$this->rules[]=$type;
else
$this->rules[]=new Rule($type,$prompt,$value);
public function jsonSerialize(){
return ["identifier"=>$this->identifier,"rules"=>$this->rules];
public function setDepends($depends) {
$this->depends=$depends;
public function setOptional($optional) {
$this->optional=$optional;