File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed
tests/lib/Integration/Fields Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change 1919use LaravelJsonApi \Core \Schema \Concerns \Sortable ;
2020use LaravelJsonApi \Eloquent \Contracts \Fillable ;
2121use LaravelJsonApi \Validation \Fields \IsValidated ;
22+ use LaravelJsonApi \Validation \Rules \ClientId ;
2223
2324class ID implements IDContract, Fillable, IsValidated
2425{
@@ -126,7 +127,7 @@ public function nullable(): self
126127 public function rulesForCreation (?Request $ request ): array |null
127128 {
128129 if ($ this ->acceptsClientIds ()) {
129- return [$ this ->validationModifier , " regex:/^ { $ this -> pattern } $/ { $ this -> flags }" ];
130+ return [$ this ->validationModifier , new ClientId ( $ this ) ];
130131 }
131132
132133 return null ;
Original file line number Diff line number Diff line change 1717use LaravelJsonApi \Eloquent \Fields \ID ;
1818use LaravelJsonApi \Eloquent \Tests \Integration \TestCase ;
1919use LaravelJsonApi \Validation \Fields \IsValidated ;
20+ use LaravelJsonApi \Validation \Rules \ClientId ;
2021
2122class IdTest extends TestCase
2223{
@@ -61,7 +62,7 @@ public function testIsValidatedWhenClientId(): void
6162 $ id = ID ::make ()->clientIds ();
6263
6364 $ this ->assertInstanceOf (IsValidated::class, $ id );
64- $ this ->assertSame (['required ' , ' regex:/^[0-9]+$/iD ' ], $ id ->rulesForCreation (null ));
65+ $ this ->assertEquals (['required ' , new ClientId ( $ id ) ], $ id ->rulesForCreation (null ));
6566 $ this ->assertNull ($ id ->rulesForUpdate (null , new \stdClass ()));
6667 }
6768
@@ -70,7 +71,7 @@ public function testIsValidatedWhenNullableClientId(): void
7071 $ id = ID ::make ()->clientIds ()->nullable ();
7172
7273 $ this ->assertInstanceOf (IsValidated::class, $ id );
73- $ this ->assertSame (['nullable ' , ' regex:/^[0-9]+$/iD ' ], $ id ->rulesForCreation (null ));
74+ $ this ->assertEquals (['nullable ' , new ClientId ( $ id ) ], $ id ->rulesForCreation (null ));
7475 $ this ->assertNull ($ id ->rulesForUpdate (null , new \stdClass ()));
7576 }
7677
You can’t perform that action at this time.
0 commit comments