Browse files

Updat ereadm

  • Loading branch information...
1 parent fbd1bf6 commit 405f24772eb9fc5b8d0feb6adef1a1cd2b9e6147 @c9s committed Sep 16, 2012
Showing with 27 additions and 3 deletions.
  1. +27 −3 README.md
View
30 README.md
@@ -14,34 +14,58 @@
- `ValidationKit\StringLengthValidator`
- `ValidationKit\StringValidator`
-## PatternValidator
+## 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 message, validator
+provides its custom msgid for message mapping, you
+can simply override the message dictionary to customize
+your messages.
+
+### PatternValidator
```php
<?php
+ use ValidationKit\PatternValidator;
$validator = new PatternValidator( '#test test test#' );
$bool = $validator->validate( $value );
$msgs = $validator->getMessages();
```
-## StringValidator
+### StringValidator
```php
<?php
+ use ValidationKit\StringValidator;
$validator = new StringValidator(array(
'starts_with' => '....' ,
'ends_with' => ... ,
'is' => ...,
'contains' => ...,
'except' => ...,
+ ), array(
+ 'invalid' => 'general invalid message',
+ 'starts_with_error' => 'error message'
));
$bool = $validator->validate( $string );
$msgs = $validator->getMessages();
+ foreach( $msgs as $msg ) {
+ echo $msg, "\n";
+ }
```
-## RangeValidator
+### RangeValidator
```php
<?php
+ use ValidationKit\RangeValidator;
$validator = new RangeValidator(array(
'greater_than' => 100,
'less_than' => 200,

0 comments on commit 405f247

Please sign in to comment.