Skip to content

Commit

Permalink
bug fix in src/Validation/Rules.php
Browse files Browse the repository at this point in the history
  • Loading branch information
amirfaramarzi committed Sep 9, 2021
1 parent 0e9ef9d commit a6aed7d
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/Validation/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait Rules
{
protected function required(array $parameters): void
{
$data = $this->get($this->data , $parameters['rule']);
$data = $this->getData($this->data , $parameters['rule']);
if (str_contains($parameters['rule'] , '*') && $data) {
foreach ($data as $index => $item){
if (!$item || !isset($index) || empty($item)){
Expand All @@ -25,7 +25,7 @@ protected function required(array $parameters): void

protected function string(array $parameters): void
{
$data = $this->get($this->data , $parameters['rule']);
$data = $this->getData($this->data , $parameters['rule']);
if (str_contains($parameters['rule'] , '*') && $data) {
foreach ($data as $index => $item){
if ($item && !is_string($item)){
Expand All @@ -41,7 +41,7 @@ protected function string(array $parameters): void

protected function integer(array $parameters): void
{
$data = $this->get($this->data , $parameters['rule']);
$data = $this->getData($this->data , $parameters['rule']);
if (str_contains($parameters['rule'] , '*') && $data) {
foreach ($data as $index => $item){
if ($item && !is_int($item)){
Expand All @@ -57,7 +57,7 @@ protected function integer(array $parameters): void

protected function boolean(array $parameters): void
{
$data = $this->get($this->data , $parameters['rule']);
$data = $this->getData($this->data , $parameters['rule']);
if (str_contains($parameters['rule'] , '*') && $data) {
foreach ($data as $index => $item){
if ($item && !is_bool($item)){
Expand All @@ -73,7 +73,7 @@ protected function boolean(array $parameters): void

protected function array(array $parameters): void
{
$data = $this->get($this->data , $parameters['rule']);
$data = $this->getData($this->data , $parameters['rule']);
if (str_contains($parameters['rule'] , '*') && $data) {
foreach ($data as $index => $item){
if ($item && !is_array($item)){
Expand All @@ -89,7 +89,7 @@ protected function array(array $parameters): void

protected function email(array $parameters): void
{
$data = $this->get($this->data , $parameters['rule']);
$data = $this->getData($this->data , $parameters['rule']);
if (str_contains($parameters['rule'] , '*') && $data) {
foreach ($data as $index => $item){
if ($item && false === filter_var($item, FILTER_VALIDATE_EMAIL)){
Expand All @@ -105,7 +105,7 @@ protected function email(array $parameters): void

protected function regex(array $parameters): void
{
$data = $this->get($this->data , $parameters['rule']);
$data = $this->getData($this->data , $parameters['rule']);
if (str_contains($parameters['rule'] , '*') && $data) {
foreach ($data as $index => $item){
if ($item && !preg_match($parameters['value'], $item)){
Expand All @@ -121,7 +121,7 @@ protected function regex(array $parameters): void

protected function notRegex(array $parameters): void
{
$data = $this->get($this->data , $parameters['rule']);
$data = $this->getData($this->data , $parameters['rule']);
if (str_contains($parameters['rule'] , '*') && $data) {
foreach ($data as $index => $item){
if ($item && preg_match($parameters['value'], $item)){
Expand All @@ -137,7 +137,7 @@ protected function notRegex(array $parameters): void

protected function max(array $parameters): void
{
$data = $this->get($this->data , $parameters['rule']);
$data = $this->getData($this->data , $parameters['rule']);
if (str_contains($parameters['rule'] , '*') && $data) {
foreach ($data as $index => $item){
if ($item){
Expand Down Expand Up @@ -166,7 +166,7 @@ protected function max(array $parameters): void

protected function min(array $parameters): void
{
$data = $this->get($this->data , $parameters['rule']);
$data = $this->getData($this->data , $parameters['rule']);
if (str_contains($parameters['rule'] , '*') && $data) {
foreach ($data as $index => $item){
if ($item){
Expand Down Expand Up @@ -195,7 +195,7 @@ protected function min(array $parameters): void

protected function size(array $parameters): void
{
$data = $this->get($this->data , $parameters['rule']);
$data = $this->getData($this->data , $parameters['rule']);
if (str_contains($parameters['rule'] , '*') && $data) {
foreach ($data as $index => $item){
if ($item){
Expand Down Expand Up @@ -224,7 +224,7 @@ protected function size(array $parameters): void

protected function date(array $parameters): void
{
$data = $this->get($this->data , $parameters['rule']);
$data = $this->getData($this->data , $parameters['rule']);
if (str_contains($parameters['rule'] , '*') && $data) {
foreach ($data as $index => $item){
if ($item && !$this->validateDate($item , is_null($parameters['value']) ? 'Y-m-d H:i:s' : $parameters['value'])){
Expand All @@ -240,8 +240,8 @@ protected function date(array $parameters): void

protected function after(array $parameters): void
{
$data = $this->get($this->data , $parameters['rule']);
$value = $this->get($this->data , $parameters['value']);
$data = $this->getData($this->data , $parameters['rule']);
$value = $this->getData($this->data , $parameters['value']);
if (str_contains($parameters['rule'] , '*') && $data) {
foreach ($data as $index => $item){
if ($item && $value && $item <= $value){
Expand All @@ -257,8 +257,8 @@ protected function after(array $parameters): void

protected function before(array $parameters): void
{
$data = $this->get($this->data , $parameters['rule']);
$value = $this->get($this->data , $parameters['value']);
$data = $this->getData($this->data , $parameters['rule']);
$value = $this->getData($this->data , $parameters['value']);
if (str_contains($parameters['rule'] , '*') && $data) {
foreach ($data as $index => $item){
if ($item && $value && $item >= $value){
Expand All @@ -274,7 +274,7 @@ protected function before(array $parameters): void

protected function in(array $parameters): void
{
$data = $this->get($this->data , $parameters['rule']);
$data = $this->getData($this->data , $parameters['rule']);
$array = explode(',' , $parameters['value']);
if (str_contains($parameters['rule'] , '*') && $data) {
foreach ($data as $index => $item){
Expand All @@ -291,7 +291,7 @@ protected function in(array $parameters): void

protected function nationalCode(array $parameters): void
{
$data = $this->get($this->data , $parameters['rule']);
$data = $this->getData($this->data , $parameters['rule']);
if (str_contains($parameters['rule'] , '*') && $data) {
foreach ($data as $index => $item){
if ($item){
Expand Down Expand Up @@ -349,7 +349,7 @@ protected function nationalCode(array $parameters): void

protected function exists(array $parameters): void
{
$data = $this->get($this->data , $parameters['rule']);
$data = $this->getData($this->data , $parameters['rule']);
if (str_contains($parameters['rule'] , '*') && $data) {
foreach ($data as $index => $item){
if ($item){
Expand All @@ -373,7 +373,7 @@ protected function exists(array $parameters): void

protected function unique(array $parameters): void
{
$data = $this->get($this->data , $parameters['rule']);
$data = $this->getData($this->data , $parameters['rule']);
if (str_contains($parameters['rule'] , '*') && $data) {
foreach ($data as $index => $item){
if ($item){
Expand Down

0 comments on commit a6aed7d

Please sign in to comment.