File size: 743 Bytes
e4f4821
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

namespace SimpleValidator\Validators;

abstract class Base
{
    protected $field = '';
    protected $error_message = '';
    protected $data = array();

    abstract public function execute(array $data);

    public function __construct($field, $error_message)
    {
        $this->field = $field;
        $this->error_message = $error_message;
    }

    public function getErrorMessage()
    {
        return $this->error_message;
    }

    public function getField()
    {
        if (is_array($this->field)) {
            return $this->field[0];
        }

        return $this->field;
    }

    public function isFieldNotEmpty(array $data)
    {
        return isset($data[$this->field]) && $data[$this->field] !== '';
    }
}