spatie / laravel-enum

Laravel support for spatie/enum
https://spatie.be/open-source
MIT License
341 stars 37 forks source link

Update EnumRule.php #77

Closed chuoke closed 3 years ago

chuoke commented 3 years ago

The 'attribute' should not be replaced. Laravel's behavior should be used.

For example:

public function rules()
    {
        return [
            'attachments.*.type' => [new EnumRule(AttachmentType::class)],
        ];
    }

public function attributes()
    {
        return [
            'attachments.*.type' => 'Attachment type',
        ];
    }

The error message: Before

The attachments.0.type field is not a valid Rules\AttachmentType.

After

The Attachment type field is not a valid Rules\AttachmentType.

And we can publish translation and change it

The :attribute is not valid.

will be

The Attachment type is not valid.
Gummibeer commented 3 years ago

https://github.com/spatie/laravel-enum/releases/tag/2.5.2