예제 #1
0
 public function setup_validations()
 {
     parent::setup_validations();
     if ($this->required || !$this->blank) {
         $this->validations[] = "float";
     }
 }
예제 #2
0
 public function validate()
 {
     parent::validate();
     if (!$this->blank) {
         $this->valid_format("email", '/^[_a-zA-Z0-9-]+(\\.[_a-zA-Z0-9-\\+]+)*@[a-zA-Z0-9-]+(\\.[a-zA-z0-9-]+)*(\\.[a-zA-Z]{2,4})$/i');
     }
 }
예제 #3
0
 public function testCanSetData()
 {
     $char = new CharField();
     $char->setData('test_data');
     $this->assertEquals($char->getRaw(), 'test_data');
     $this->assertEquals($char->getData(), 'test_data');
     $char->setName('test');
     $char->setErrorMessages(['error' => 'error message']);
     $this->assertTrue(is_array($char->getErrorMessages()));
     $this->assertEquals('test', $char->getName());
 }
예제 #4
0
 public function getFormField($form, $fieldClass = null, array $extra = [])
 {
     return parent::getFormField($form, \Mindy\Form\Fields\PasswordField::className(), $extra);
 }
예제 #5
0
파일: Field.php 프로젝트: ricobl/frix
	function __construct ($name, $options = array()) {
		
		// Block having a default value
		unset($this->default);
		unset($options['default']);
		
		// Call the default constructor
		parent::__construct($name, $options);
		
	}
예제 #6
0
 public function testCharFieldValidationErrorShouldSanitize()
 {
     try {
         $f = new CharField(array('regex' => '/^a/'));
         $f->clean('<xss></xss>bc');
     } catch (ValidationError $e) {
         $this->assertEquals('bc', $e->getCleanedValue());
     }
 }
예제 #7
0
파일: SlugField.php 프로젝트: Edke/PerfORM
 /**
  * Validates field's errors and returns them as array
  * @return array
  */
 public function validate()
 {
     if (is_null($this->sourceField)) {
         $this->_addError("required option auto_source was not set");
     } elseif (!$this->getModel()->hasField($this->sourceField)) {
         $this->_addError("auto_source field '{$this->sourceField}' does not exists");
     }
     return parent::validate();
 }