From 8d090438b659b641dd0f6cbc99193f3b48b2fc4b Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Mon, 7 Oct 2019 21:59:40 +0200 Subject: Validation rules: min/max/between: Use string length to compare strings --- src/Http/Validation/Rules/StringInputLength.php | 44 +++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/Http/Validation/Rules/StringInputLength.php (limited to 'src/Http/Validation/Rules/StringInputLength.php') diff --git a/src/Http/Validation/Rules/StringInputLength.php b/src/Http/Validation/Rules/StringInputLength.php new file mode 100644 index 00000000..7b5c248b --- /dev/null +++ b/src/Http/Validation/Rules/StringInputLength.php @@ -0,0 +1,44 @@ +isDateTime($input) + ) { + $input = Str::length($input); + } + + return parent::validate($input); + } + + /** + * @param mixed $input + * @return bool + */ + protected function isDateTime($input): bool + { + try { + new DateTime($input); + } catch (Throwable $e) { + return false; + } + + return true; + } +} -- cgit v1.2.3-54-g00ecf