spatie / laravel-enum

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

Add toRule method to Enum base class #66

Closed iamohd-zz closed 3 years ago

iamohd-zz commented 3 years ago

This PR will make setting enum rules cleaner.

It allows to do the following:

$rules = [
    'status' => StatusEnum::rule(),
];

instead of doing this

$rules = [
    'status' => new EnumRule(StatusEnum::class),
];
Gummibeer commented 3 years ago

Hey,

Thanks for this idea! 🙏 Real good one.

But in that way the possibility that it's conflicting with a users enum values is too high. 😔

We have several toXyz() methods already. I think that a toRule() method is same useful but less conflicting!? Could you rename it?

iamohd-zz commented 3 years ago

@Gummibeer That's right, it's renamed. Thanks

Gummibeer commented 3 years ago

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