8000 New Useful functions by rk-chr · Pull Request #3 · p-rk/js-utility-functions · GitHub
[go: up one dir, main page]

Skip to content

New Useful functions #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

# Javascript Utility functions

[![npm][npm]][npm-url]
[![Build Status](https://travis-ci.org/p-rk/js-utility-functions.svg?branch=master)](https://travis-ci.org/p-rk/js-utility-functions)
[![Coverage Status](https://coveralls.io/repos/github/p-rk/js-utility-functions/badge.svg?branch=master)](https://coveralls.io/github/p-rk/js-utility-functions?branch=master)


## Example
Expand All @@ -19,6 +21,11 @@ $ npm install js-utility-functions --save
* Count Instance in an array
* Sum of an Array [Optional Add Initial Value]

* Validate Name
* Validate Mobile number
* Validate email
* Validate Option

```Javascript

// ES 2015
Expand Down Expand Up @@ -98,3 +105,70 @@ console.log(x);
// Output : 31

```

- - - -

```Javascript

import { validateName } from 'js-utility-functions';

let x = validateName("ra", "Enter Valid Name", 3);
// First argument is value
// Second argument is your custom error message
// Third argument is length of the value you want to validate (optional)
console.log(x);

// Output : {error: true, errorMessage: 'Enter Valid Name'}


import { validateMobile } from 'js-utility-functions';

let x = validateMobile(9999999999, 'Enter Valid Mobile Number');

//validate 10 digit mobile number

console.log(x);

// Output : {error: false, errorMessage: ''}


import { validateEmail } from 'js-utility-functions';

let x = validateMobile('rama.ped', 'Enter Valid Email ID');

//validate 10 digit mobile number

console.log(x);

// Output : {error: true, errorMessage: 'Enter Valid Email ID'}


import { validateOption } from 'js-utility-functions';

let x = validateOption('option', 'Select Valid Option');

//validate an option select

console.log(x);

// Output : {error: false, errorMessage: ''}


For All Validation functions return following object

Error Case:

{error: true, errorMessage: 'Your custom message that is passed'}

No Error Case:

{error: false, errorMessage: ''}

```

## License

MIT

[npm]: https://img.shields.io/npm/v/js-utility-functions.svg
[npm-url]: https://www.npmjs.com/package/js-utility-functions
Loading
0