FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

update validation logic · JavaDevl/framework@92a3b24 · GitHub

Commit 92a3b24

Browse files
committed
update validation logic
1 parent cf4c435 commit 92a3b24

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

‎src/Illuminate/Foundation/Application.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
2525
*
2626
* @var string
2727
*/
28-
const VERSION = '5.2.1';
28+
const VERSION = '5.2.2';
2929

3030
/**
3131
* The base path for the Laravel installation.

‎src/Illuminate/Validation/Validator.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ protected function validateArray($attribute, $value)
806806
return true;
807807
}
808808

809-
return is_array($value);
809+
return is_null($value) || is_array($value);
810810
}
811811

812812
/**
@@ -824,7 +824,7 @@ protected function validateBoolean($attribute, $value)
824824

825825
$acceptable = [true, false, 0, 1, '0', '1'];
826826

827-
return in_array($value, $acceptable, true);
827+
return is_null($value) || in_array($value, $acceptable, true);
828828
}
829829

830830
/**
@@ -840,7 +840,7 @@ protected function validateInteger($attribute, $value)
840840
return true;
841841
}
842842

843-
return filter_var($value, FILTER_VALIDATE_INT) !== false;
843+
return is_null($value) || filter_var($value, FILTER_VALIDATE_INT) !== false;
844844
}
845845

846846
/**
@@ -856,7 +856,7 @@ protected function validateNumeric($attribute, $value)
856856
return true;
857857
}
858858

859-
return is_numeric($value);
859+
return is_null($value) || is_numeric($value);
860860
}
861861

862862
/**
@@ -872,7 +872,7 @@ protected function validateString($attribute, $value)
872872
return true;
873873
}
874874

875-
return is_string($value);
875+
return is_null($value) || is_string($value);
876876
}
877877

878878
/**

‎tests/Validation/ValidationValidatorTest.php‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,8 +1874,14 @@ public function testThatPrimitiveTypesAreImplicitAndMustBeCorrectIfDataIsPresent
18741874
$v = new Validator($trans, [], ['foo' => 'numeric']);
18751875
$this->assertTrue($v->passes());
18761876

1877+
// Allow null on these rules unless required
18771878
$trans = $this->getRealTranslator();
18781879
$v = new Validator($trans, ['foo' => null], ['foo' => 'numeric']);
1880+
$this->assertFalse($v->fails());
1881+
1882+
// Allow null on these rules unless required
1883+
$trans = $this->getRealTranslator();
1884+
$v = new Validator($trans, ['foo' => null], ['foo' => 'required|numeric']);
18791885
$this->assertTrue($v->fails());
18801886

18811887
$trans = $this->getRealTranslator();

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL