Skip to content

Commit

Permalink
Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
IonicaBizau committed May 25, 2016
1 parent 5d941f6 commit 6cd4f95
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 11 deletions.
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Contributions are more than welcome!

Thanks! :sweat_smile:



[1]: https://github.com/IonicaBizau/validate5/issues

[2]: https://github.com/IonicaBizau/code-style
[2]: https://github.com/IonicaBizau/code-style
63 changes: 63 additions & 0 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
## Documentation

You can see below the API reference of this module.

### `validate5(forms)`
Handles the submit event on the selected forms.

You may want to extend the `validate5.patterns` object with custom types. By default it has validation for:

- `email`: `[emailRegex, "Invalid email address"]`

e.g. `validate5.patterns.myCustomType = [/^[0-9]+$/g, "Not a number."]`

Use the `validate5.skips` array to handle elements that should be skipped when validating. By default it skips the `type=submit` inputs.

e.g.

```js
validate5.skips.push(function (c) {
if (c.getattribute("data-ignore-validation")) { return true; }
});
```

#### Params
- **String** `forms`: The form(s) selector you want to automagically validate on submit.

### `validateInput(input)`
Validates an input element.

#### Params
- **HTMLElement** `input`: The input to validate.

#### Return
- **Validify** The [`validify`](https://github.com/IonicaBizau/validify) result.

### `inputs(formElm, cb)`
Iterate the inputs in the provided form.

#### Params
- **HTMLElement** `formElm`: The form element.
- **Function** `cb`: The callback function.

#### Return
- **Array** The array of inputs.

### `validateForm(formElm)`
Validates the form element.

#### Params
- **HTMLElement** `formElm`: The form element.

#### Return
- **Array** An array of errors.

### `showErrors(formElm)`
Validates the form and displays the errors.

#### Params
- **HTMLElement** `formElm`: The `<form>` element to validate.

#### Return
- **Array|Boolean** An array of errors or `false` if all the fields are valid.

26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# validate5 [![PayPal](https://img.shields.io/badge/%24-paypal-f39c12.svg)][paypal-donations] [![Version](https://img.shields.io/npm/v/validate5.svg)](https://www.npmjs.com/package/validate5) [![Downloads](https://img.shields.io/npm/dt/validate5.svg)](https://www.npmjs.com/package/validate5) [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/johnnyb?utm_source=github&utm_medium=button&utm_term=johnnyb&utm_campaign=github)

# validate5

[![PayPal](https://img.shields.io/badge/%24-paypal-f39c12.svg)][paypal-donations] [![AMA](https://img.shields.io/badge/ask%20me-anything-1abc9c.svg)](https://github.com/IonicaBizau/ama) [![Version](https://img.shields.io/npm/v/validate5.svg)](https://www.npmjs.com/package/validate5) [![Downloads](https://img.shields.io/npm/dt/validate5.svg)](https://www.npmjs.com/package/validate5) [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/johnnyb?utm_source=github&utm_medium=button&utm_term=johnnyb&utm_campaign=github)

> Form validations made easy.
[![validate5](http://i.imgur.com/tLbLEeJ.png)](http://ionicabizau.github.io/validate5/example)

## :cloud: Installation


Check out the [`dist`](/dist) directory to download the needed files and include them on your page.

Expand All @@ -15,10 +18,10 @@ If you're using this module in a CommonJS environment, you can install it from `
$ npm i --save validate5
```


## :clipboard: Example



```js
/**
Expand All @@ -43,9 +46,10 @@ $ npm i --save validate5
// To validate the forms on submit, use:
validate5("form");
```

## :memo: Documentation


### `validate5(forms)`
Handles the submit event on the selected forms.

Expand Down Expand Up @@ -105,18 +109,20 @@ Validates the form and displays the errors.
#### Return
- **Array|Boolean** An array of errors or `false` if all the fields are valid.



## :yum: How to contribute
Have an idea? Found a bug? See [how to contribute][contributing].


## :scroll: License

[MIT][license] © [Ionică Bizău][website]

[paypal-donations]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RVXDDLKKLQRJW
[donate-now]: http://i.imgur.com/6cMbHOC.png

[license]: http://showalicense.com/?fullname=Ionic%C4%83%20Biz%C4%83u%20%3Cbizauionica%40gmail.com%3E%20(http%3A%2F%2Fionicabizau.net)&year=2016#license-mit
[website]: http://ionicabizau.net
[contributing]: /CONTRIBUTING.md
[docs]: /DOCUMENTATION.md
[docs]: /DOCUMENTATION.md

0 comments on commit 6cd4f95

Please sign in to comment.