@@ -24,7 +24,7 @@ public function testDefaultDateRule()
24
24
public function testDateFormatRule ()
25
25
{
26
26
$ rule = Rule::date ()->format ('d/m/Y ' );
27
- $ this ->assertEquals ('date| date_format:d/m/Y ' , (string ) $ rule );
27
+ $ this ->assertEquals ('date_format:d/m/Y ' , (string ) $ rule );
28
28
}
29
29
30
30
public function testAfterTodayRule ()
@@ -49,30 +49,45 @@ public function testAfterSpecificDateRule()
49
49
{
50
50
$ rule = Rule::date ()->after (Carbon::parse ('2024-01-01 ' ));
51
51
$ this ->assertEquals ('date|after:2024-01-01 ' , (string ) $ rule );
52
+
53
+ $ rule = Rule::date ()->format ('d/m/Y ' )->after (Carbon::parse ('2024-01-01 ' ));
54
+ $ this ->assertEquals ('date_format:d/m/Y|after:01/01/2024 ' , (string ) $ rule );
52
55
}
53
56
54
57
public function testBeforeSpecificDateRule ()
55
58
{
56
59
$ rule = Rule::date ()->before (Carbon::parse ('2024-01-01 ' ));
57
60
$ this ->assertEquals ('date|before:2024-01-01 ' , (string ) $ rule );
61
+
62
+ $ rule = Rule::date ()->format ('d/m/Y ' )->before (Carbon::parse ('2024-01-01 ' ));
63
+ $ this ->assertEquals ('date_format:d/m/Y|before:01/01/2024 ' , (string ) $ rule );
58
64
}
59
65
60
66
public function testAfterOrEqualSpecificDateRule ()
61
67
{
62
68
$ rule = Rule::date ()->afterOrEqual (Carbon::parse ('2024-01-01 ' ));
63
69
$ this ->assertEquals ('date|after_or_equal:2024-01-01 ' , (string ) $ rule );
70
+
71
+ $ rule = Rule::date ()->format ('d/m/Y ' )->afterOrEqual (Carbon::parse ('2024-01-01 ' ));
72
+ $ this ->assertEquals ('date_format:d/m/Y|after_or_equal:01/01/2024 ' , (string ) $ rule );
64
73
}
65
74
66
75
public function testBeforeOrEqualSpecificDateRule ()
67
76
{
68
77
$ rule = Rule::date ()->beforeOrEqual (Carbon::parse ('2024-01-01 ' ));
69
78
$ this ->assertEquals ('date|before_or_equal:2024-01-01 ' , (string ) $ rule );
79
+
80
+ $ rule = Rule::date ()->format ('d/m/Y ' )->beforeOrEqual (Carbon::parse ('2024-01-01 ' ));
81
+ $ this ->assertEquals ('date_format:d/m/Y|before_or_equal:01/01/2024 ' , (string ) $ rule );
70
82
}
71
83
72
84
public function testBetweenDatesRule ()
73
85
{
74
86
$ rule = Rule::date ()->between (Carbon::parse ('2024-01-01 ' ), Carbon::parse ('2024-02-01 ' ));
75
87
$ this ->assertEquals ('date|after:2024-01-01|before:2024-02-01 ' , (string ) $ rule );
88
+
89
+ $ rule = Rule::date ()->format ('d/m/Y ' )->between (Carbon::parse ('2024-01-01 ' ), Carbon::parse ('2024-02-01 ' ));
90
+ $ this ->assertEquals ('date_format:d/m/Y|after:01/01/2024|before:01/02/2024 ' , (string ) $ rule );
76
91
}
77
92
78
93
public function testBetweenOrEqualDatesRule ()
@@ -87,7 +102,7 @@ public function testChainedRules()
87
102
->format ('Y-m-d ' )
88
103
->after ('2024-01-01 00:00:00 ' )
89
104
->before ('2025-01-01 00:00:00 ' );
90
- $ this ->assertEquals ('date| date_format:Y-m-d|after:2024-01-01 00:00:00|before:2025-01-01 00:00:00 ' , (string ) $ rule );
105
+ $ this ->assertEquals ('date_format:Y-m-d|after:2024-01-01 00:00:00|before:2025-01-01 00:00:00 ' , (string ) $ rule );
91
106
92
107
$ rule = Rule::date ()
93
108
->format ('Y-m-d ' )
@@ -97,7 +112,7 @@ public function testChainedRules()
97
112
->unless (true , function ($ rule ) {
98
113
$ rule ->before ('2025-01-01 ' );
99
114
});
100
- $ this ->assertSame ('date| date_format:Y-m-d|after:2024-01-01 ' , (string ) $ rule );
115
+ $ this ->assertSame ('date_format:Y-m-d|after:2024-01-01 ' , (string ) $ rule );
101
116
}
102
117
103
118
public function testDateValidation ()
0 commit comments