Skip to content

Commit

Permalink
[UPD] remove useless field value on constructor, it will be get from …
Browse files Browse the repository at this point in the history
…data_source.
  • Loading branch information
bim-g committed Dec 8, 2022
1 parent a45f545 commit 16e96b2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Validate.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function check(array $resource, array $schema){

$reflexion = new ReflectionClass($class_name);

$instance = $reflexion->newInstance($item, $value,$resource);
$instance = $reflexion->newInstance($item,$resource);

foreach ($rules[$key] as $method => $params){
if(method_exists($instance,$method)){
Expand Down
6 changes: 3 additions & 3 deletions src/Validator/BooleanValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
final class BooleanValidator extends ValidatorProvider
{

function __construct(string $string_item,string $value,array $source)
function __construct(string $item, array $source)
{
$this->field_name = $string_item;
$this->field_name = $item;
$this->data_source = $source;
$this->field_value = $source[$this->field_name];
$this->class_provider = "boolean";

if ($this->isBoolean()) {
$this->field_value = $source[$string_item];
$this->field_value = $source[$item];
};
parent::__construct();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Validator/DateValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
final class DateValidator extends ValidatorProvider
{

public function __construct(string $item,string $value,array $source ) {
$this->field_value = $source[$item];
public function __construct(string $item,array $data_source ) {
$this->field_name = $item;
$this->data_source = $source;
$this->field_value = $data_source[$item];
$this->data_source = $data_source;
$this->class_provider = "date";
$this->checkExist();
parent::__construct();
Expand Down
10 changes: 5 additions & 5 deletions src/Validator/NumberValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
*/
final class NumberValidator extends ValidatorProvider {

function __construct(string $string_item,string $value,array $source) {
$this->data_source = $source;
$this->field_name = $string_item;
$this->field_value= $value;
function __construct(string $item, array $data_source) {
$this->data_source = $data_source;
$this->field_name = $item;
$this->field_value = $data_source[$item];
$this->class_provider = "number";
if($this->isNumber()){
$this->field_value = $source[$string_item];
$this->field_value = $data_source[$item];
}
parent::__construct();
}
Expand Down
9 changes: 4 additions & 5 deletions src/Validator/StringValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
final class StringValidator extends ValidatorProvider {
/**
*
* @param string $item the item to be validated.
* @param string $value the value of the item
* @param array $data_source the source data from where is going to check it the match key exist and have value.
* @param string $item the item to be validated.
* @param array $data_source the source data from where is going to check it the match key exist and have value.
*/
public function __construct(string $item, string $value, array $data_source=[]) {
public function __construct(string $item, array $data_source=[]) {
$this->errors = [];
$this->data_source = $data_source;
$this->field_name = $item;
$this->field_value = $value;
$this->field_value = $data_source[$item];
$this->class_provider = "string";
parent::__construct();
}
Expand Down

0 comments on commit 16e96b2

Please sign in to comment.