Skip to content

Commit

Permalink
update asynchronous validation example in readme (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaareloun authored and mikeerickson committed Aug 18, 2019
1 parent 7cdb58f commit 1732a7d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ Validator.registerAsync('username_available', function(username, attribute, req,
});
```

Then call your validator passing a callback to `fails` or `passes` like so:
Then call your validator using `checkAsync` passing `fails` and `passes` callbacks like so:

```js
let validator = new Validator({
Expand All @@ -390,16 +390,17 @@ let validator = new Validator({
username: 'required|min:3|username_available'
});

validator.passes(function() {
function passes() {
// Validation passed
});
}

validator.fails(function() {
function fails() {
validator.errors.first('username');
});
```
}

validator.checkAsync(passes, fails);

Note: if you attempt to call `passes` or `fails` without a callback and the validator detects there are asynchronous validation rules, an exception will be thrown.
```

### Error Messages

Expand Down

0 comments on commit 1732a7d

Please sign in to comment.