besanek / const-validator
Simple tester for validating value given by constant.
Installs: 11
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/besanek/const-validator
Requires (Dev)
- nette/tester: @dev
This package is auto-updated.
Last update: 2025-10-10 23:34:24 UTC
README
Validating parameters defined by constants.
Simple example
Because simple example is better than a thousand words.
User entity (without PHPDoc, constructor, getters, etc.):
<?php use ConstValidator\Validator as Constant; class UserEntity { private $role; public function setRole($role) { if(!Constant::validate("UserEntity::ROLE_*", $role)){ throw new Exception("Invalid role"); } $this->role = $role; } const ROLE_MEMBER = 'member'; const ROLE_MODERATOR = 'moderator'; const ROLE_ADMIN = 'admin'; }