Skip to content

Commit

Permalink
Merge pull request #22 from berry-langerak/feature/introducing-docs
Browse files Browse the repository at this point in the history
Feature/introducing docs
  • Loading branch information
berry-langerak committed Apr 12, 2015
2 parents ce1c1ef + 102a54d commit dfe9f66
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/extending.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Extending Validator
6 changes: 6 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Particle Validator

Particle\Validator is a small and elegant validation library, with an extremely clean API
which makes validation **fun**!


19 changes: 19 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Installation

Installing Particle\Validator is very easy, if you're using [composer](http://getcomposer.com).
If you haven't done so, install composer, and use `composer require` to install Particle\Validator.

```bash
curl -sS https://getcomposer.org/installer | php
php composer.phar require particle/validator
```

## First usage

To make sure all Particle\Validator classes can be autoloaded, you have to include "vendor/autoload.php":

```php
require_once __DIR__ . '/../vendor/autoload.php';

$v = new Particle\Validator;
```
1 change: 1 addition & 0 deletions docs/messages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Overwriting the default messages
78 changes: 78 additions & 0 deletions docs/rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Default rules

There is a large number of default rules in Particle\Validator.

## Required and allowEmpty

Required and optional are special cases within Particle\Validator. They are only about whether or not the *key* is
required, not the value. In case of a non-required value, you may use allowEmpty, which is the third parameter to
`required` and `optional`.

## List of rules

### alnum($allowWhitespace = false)

Validate the value to consist only out of alphanumeric characters.

### alpha($allowWhitespace = false)

Validate that the value only consists our of alphabetic characters.

### between($min, $max, $inclusive = true)

Validate that the value is between $min and $max (inclusive by default).

### callback(callable $callable)

Validate by executing a callback function, and returning its result.

### datetime($format = null)

Validates that the value is a date. If format is passed, it *must* be in that format.

### digits()

Validates that all characters of the value are decimal digits.

### integer()

Validates the value represents a valid integer

### email()

Validates that the value is a valid email address (format only).

### equals($value)

Validates that the value is equal to $value.

### inArray(array $array, $strict = true)

Validates that the value is in the array with optional "loose" checking.

### length($length)

Validate the value to be of precisely length $length.

### lengthBetween($min, $max, $inclusive = true)

Validates that the length of the value is between $min and $max.
If $max is null, it has no upper limit. The default is inclusive.

### regex($regex)

Validates that the value matches the regular expression $regex.

### url()

Validates that the value is a valid URL.

### required(callable $callback)

Set a callable which may be used to alter the required requirement on validation time.
This may be incredibly helpful when doing conditional validation.

### allowEmpty(callable $callback)

Set a callable which may be used to alter the allow empty requirement on validation time.
This may be incredibly helpful when doing conditional validation.
Empty file added docs/usage.md
Empty file.
9 changes: 9 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
site_name: Particle Validator
theme: readthedocs
pages:
- [index.md, Home]
- [installation.md, Installing]
- [rules.md, Default rules]
- [messages.md, Overwriting messages]
- [extending.md, Extending the Validator]

0 comments on commit dfe9f66

Please sign in to comment.