diff --git a/src/Sanitizers/CarbonDateSanitizer.php b/src/Sanitizers/CarbonDateSanitizer.php new file mode 100644 index 0000000..b30f320 --- /dev/null +++ b/src/Sanitizers/CarbonDateSanitizer.php @@ -0,0 +1,18 @@ +assertInstanceOf(Carbon::class, $sanitizer->sanitize($dateFormat)); + } + } + + public function test_it_will_return_null_if_the_date_is_invalid() + { + $invalidDateFormats = [ + 'derp', + 'May 33', + '2021-13-30' + ]; + + $sanitizer = new CarbonDateSanitizer(); + + foreach ($invalidDateFormats as $dateFormat) { + $this->assertNull($sanitizer->sanitize($dateFormat), "It will not parse {$dateFormat}"); + } + } +} \ No newline at end of file