Skip to content

Commit

Permalink
next release
Browse files Browse the repository at this point in the history
  • Loading branch information
bitnbytesio committed Jun 5, 2019
1 parent cac3880 commit bc3c544
Show file tree
Hide file tree
Showing 6 changed files with 340 additions and 276 deletions.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,26 @@ validator.setLang('pb');

```

### Using Custom Attribute Names

```javascript

const validator = require('node-input-validator');

let v = new validator( ctx.request.body, {
phone:'required',
dob: 'required'
});

v.setAttributeNames({
phone: 'phone number',
dob: 'Date of Birth'
});

```

In error messages you will get "phone number" instead of phone. For Example: in case required rule failed, Error message will be: The phone number field is mandatory.

### Add your own custom validation rules

```javascript
Expand Down Expand Up @@ -616,7 +636,8 @@ 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.
The field under validation must match the given regular expression.
Note: Currently regex rules break on using colon (:) or pipe delimiters.

**same**
The given field must match the field under validation.
Expand Down
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ declare class Validator {

constructor(inputs: any, rules: any, customMessages?: any = {});

setAttributeNames(niceNames: any);

static make(inputs: any, rules: any, messages: any = {}): Validator;

static create(rules: any, messages: any = {}): Validator;
Expand Down
Loading

0 comments on commit bc3c544

Please sign in to comment.