'#ef5350', ], [ 'color' => [new ColorRule], ]); // Act $isValid = $validator->passes(); $messages = $validator->messages()->toArray(); // Assert $this->assertTrue($isValid); $this->assertArrayNotHasKey('color', $messages); } public function test_validation_fails_if_value_is_not_a_string(): void { // Arrange $validator = Validator::make([ 'color' => true, ], [ 'color' => [new ColorRule], ]); // Act $isValid = $validator->passes(); $messages = $validator->messages()->toArray(); // Assert $this->assertFalse($isValid); $this->assertEquals('The color field must be a string.', $messages['color'][0]); } public function test_validation_fails_if_value_is_not_a_valid_color(): void { // Arrange $validator = Validator::make([ 'color' => 'rgb(0,0,0)', ], [ 'color' => [new ColorRule], ]); // Act $isValid = $validator->passes(); $messages = $validator->messages()->toArray(); // Assert $this->assertFalse($isValid); $this->assertEquals('The color field must be a valid color.', $messages['color'][0]); } }