Skip to content

Commit

Permalink
readme changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bitnbytesio committed Jun 11, 2019
1 parent b427b57 commit d917ce3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,21 @@ router.post('login', async function (ctx) {
let matched = await v.check();
```

### Array of rules

Usefull in case of using colon (:) / pipe delimiters in rules like dateFormat / regex.

```javascript

let v = Validator.make(
{ uid: 'abcdefghi' },
{
uid: ['required', ['lengthBetween', '5', '8'], 'alpha']
});
let matched = await v.check();

```

## Extending

Placeholder in messages, :attribute will be replaced with field name, :value with field value and :arg0, :arg1 ...n with arguments passed to rule.
Expand Down Expand Up @@ -492,6 +507,8 @@ let v = new Validator({valid:'2019-02-28'}, {valid:'required|dateBeforeToday:2,m
**dateFormat:format**
The field under validation must match the given date format.

Note: use array of rules style declaration to deal with colon (:) in time formats.

```javascript
let v = new Validator({dob:''}, {dob:'required|dateFormat:YYYY-MM-DD'});
```
Expand Down Expand Up @@ -636,8 +653,9 @@ The field under validation must be numeric.
The field under validation must be a valid phone number.

**regex**
The field under validation must match the given regular expression.
Note: Currently regex rules break on using colon (:) or pipe delimiters.
The field under validation must match the given regular expression.

Note: Currently regex rules break on using colon (:) or pipe delimiters. Use array of rules style declaration instead of string.

**same**
The given field must match the field under validation.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-input-validator",
"version": "3.3.0-rc3",
"version": "3.3.0",
"description": "validation library for nodejs, inspired by laravel.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit d917ce3

Please sign in to comment.