|
53 | 53 | expect(validator()->validate($dataToValidate1, ['item1' => 'anotherCustomRule']))->toBe(false); |
54 | 54 |
|
55 | 55 | expect(validator()->errors())->toHaveKey('item1'); |
56 | | - expect(validator()->errors()['item1'][0] ?? '')->toBe('This is a custom message'); |
| 56 | + expect(validator()->errors()['item1'] ?? '')->toBe('This is a custom message'); |
57 | 57 | }); |
58 | 58 |
|
59 | 59 | test('can add custom validation rules with closure and custom message with placeholder', function () { |
|
66 | 66 | expect(validator()->validate($dataToValidate1, ['item2' => 'anotherCustomRule']))->toBe(false); |
67 | 67 |
|
68 | 68 | expect(validator()->errors())->toHaveKey('item2'); |
69 | | - expect(validator()->errors()['item2'][0] ?? '')->toBe('This is a custom message for item2'); |
| 69 | + expect(validator()->errors()['item2'] ?? '')->toBe('This is a custom message for item2'); |
70 | 70 | }); |
71 | 71 |
|
72 | 72 | test('can add custom validation rules with closure and custom message with placeholder and custom value', function () { |
|
79 | 79 | expect(validator()->validate($dataToValidate1, ['item3' => 'anotherCustomRule']))->toBe(false); |
80 | 80 |
|
81 | 81 | expect(validator()->errors())->toHaveKey('item3'); |
82 | | - expect(validator()->errors()['item3'][0] ?? '')->toBe('This is a custom message for item3 with value not custom'); |
| 82 | + expect(validator()->errors()['item3'] ?? '')->toBe('This is a custom message for item3 with value not custom'); |
83 | 83 | }); |
84 | 84 |
|
85 | 85 | test('can add custom validation rules with regex and custom message', function () { |
|
89 | 89 | expect(validator()->validate($dataToValidate1, ['item4' => 'mustHaveTheWordAvailable']))->toBe(false); |
90 | 90 |
|
91 | 91 | expect(validator()->errors())->toHaveKey('item4'); |
92 | | - expect(validator()->errors()['item4'][0] ?? '')->toBe('This is a custom message'); |
| 92 | + expect(validator()->errors()['item4'] ?? '')->toBe('This is a custom message'); |
93 | 93 | }); |
94 | 94 |
|
95 | 95 | test('can add custom validation rules with regex and custom message with placeholder', function () { |
|
99 | 99 | expect(validator()->validate($dataToValidate1, ['item5' => 'mustHaveTheWordAvailable']))->toBe(false); |
100 | 100 |
|
101 | 101 | expect(validator()->errors())->toHaveKey('item5'); |
102 | | - expect(validator()->errors()['item5'][0] ?? '')->toBe('This is a custom message for item5'); |
| 102 | + expect(validator()->errors()['item5'] ?? '')->toBe('This is a custom message for item5'); |
103 | 103 | }); |
104 | 104 |
|
105 | 105 | test('can add custom validation rules with regex and custom message with placeholder and custom value', function () { |
|
109 | 109 | expect(validator()->validate($dataToValidate1, ['item6' => 'mustHaveTheWordAvailable']))->toBe(false); |
110 | 110 |
|
111 | 111 | expect(validator()->errors())->toHaveKey('item6'); |
112 | | - expect(validator()->errors()['item6'][0] ?? '')->toBe('This is a custom message for item6 with value not in here'); |
| 112 | + expect(validator()->errors()['item6'] ?? '')->toBe('This is a custom message for item6 with value not in here'); |
113 | 113 | }); |
0 commit comments