Download the PHP package corneltek/validationkit without Composer
On this page you can find all versions of the php package corneltek/validationkit. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package validationkit
Validation
Validators
ValidationKit\PhoneNumber\TWPhoneNumberValidator
ValidationKit\TW\IDNumberValidator
ValidationKit\CallbackValidator
ValidationKit\ChainedValidator
ValidationKit\EmailValidator
ValidationKit\PasswordValidation
ValidationKit\PatternValidator
ValidationKit\RangeValidator
ValidationKit\StringLengthValidator
ValidationKit\StringValidator
Validator Constructor
ValidationKit Validator's constructor prototype is:
__construct( $options = array() , $msgs = array() );
The $msgs() is an associative array that contains:
msg_id => msg_str
For different kind of validation messages, every validator provides its custom msgid for message mapping, you can simply override the message dictionary to customize your messages.
The following sample code shows the format of message dictionary:
The following list is the default message mapping:
- valid
- invalid
And of course you can easily extend messages in your customized validator class.
To return an invalid message in your validator:
To return an valid message in your validator:
To get the result messages from validator:
The result message is a ValidationMessage
object, there are three class
properties in ValidationMessage
:
- valid (boolean)
- id (string, message id)
- message (string, message)
EmailValidator
PatternValidator
StringLengthValidator
StringValidator
PasswordValidator
RangeValidator
Customize your validator
To write your own validator, here is the basic structure of a validator class:
You can provide your default message dictinory by defining a
getDefaultMessages
method:
Hacking
Install dependencies:
$ composer install --dev
Run unit tests:
$ phpunit