myth-auth icon indicating copy to clipboard operation
myth-auth copied to clipboard

Deprecate Validator Class

Open MGatner opened this issue 2 years ago • 3 comments

BaseValidator and ValidatorInterface provide almost identical offerings. One of these should be deprecated, depending on whether the intent. Either:

  • keep the base, adding abstract public function check() (less restriction, more changes elsewhere)
  • keep the interface, possibly convert the base to an optional trait

Either solution should account for the following:

  1. The interface still uses CodeIgniter\Entity which is deprecated
  2. The interface method specifies Entity input when most validators require User
  3. PasswordValidator is not a valid interface class because of 2)

MGatner avatar Apr 27 '22 13:04 MGatner

Maybe keep them both and use an interface to specify the contract and an abstract class as just one implementation thereof?

manageruz avatar Jun 03 '22 06:06 manageruz

Shield has figured this out, it would probably make sense to imitate the solution there: https://github.com/codeigniter4/shield/tree/develop/src/Authentication/Passwords

MGatner avatar Jun 03 '22 11:06 MGatner

So we should modify ValidatorInterface.php :

  1. Replace use CodeIgniter\Entity with Myth\Auth\Entities\User
  2. Replace public function check(string $password, ?Entity $user = null): bool method with public function check(string $password, ?User $user = null): bool
  3. Do all necessary changes to all validators to use User class instead of Entity class.

Is that's all or am i missing something else?

manageruz avatar Jun 23 '22 11:06 manageruz