-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add .gitignore and package.json files
- Loading branch information
1 parent
e8252d3
commit 1b58207
Showing
5 changed files
with
391 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Automatically normalize line endings for all text-based files | ||
# http://git-scm.com/docs/gitattributes#_end_of_line_conversion | ||
* text=auto | ||
|
||
# For the following file types, normalize line endings to LF on | ||
# checkin and prevent conversion to CRLF when they are checked out | ||
# (this is required in order to prevent newline related issues like, | ||
# for example, after the build script is run) | ||
.* text eol=lf | ||
*.css text eol=lf | ||
*.html text eol=lf | ||
*.jade text eol=lf | ||
*.js text eol=lf | ||
*.json text eol=lf | ||
*.less text eol=lf | ||
*.scss text eol=lf | ||
*.md text eol=lf | ||
*.sh text eol=lf | ||
*.txt text eol=lf | ||
*.xml text eol=lf | ||
*.vue text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,3 +128,7 @@ dist | |
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
# Ignore IDE files | ||
.idea | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,68 @@ | ||
# js-validator | ||
A versatile and easy-to-use JavaScript validation library for ensuring data integrity with extensive customization options. | ||
# JS Validator | ||
|
||
A versatile and easy-to-use JavaScript validation library, JS Validator ensures the integrity of your data inputs with a range of customization options. Ideal for projects that require detailed, flexible validation rules, from simple forms to complex data structures. | ||
|
||
## Features | ||
|
||
- Supports a wide range of data types (string, number, boolean). | ||
- Customizable validation rules (required, min/max length, regex matching, etc.). | ||
- Asynchronous and custom validation functions. | ||
- Easy error message customization. | ||
- Options for strict mode validation. | ||
- Methods for retrieving passed fields and current errors. | ||
- Fully documented and TypeScript friendly. | ||
|
||
## Installation | ||
|
||
```bash | ||
npm install [your-package-name] | ||
``` | ||
|
||
## Usage | ||
|
||
Below is a quick example of how to use the JS Validator: | ||
|
||
```javascript | ||
const Validator = require('[your-package-name]'); | ||
|
||
const rules = { | ||
email: { type: 'string', required: true, validate: 'email' }, | ||
age: { type: 'number', min: 18 }, | ||
}; | ||
|
||
const messages = { | ||
email: { required: 'Email is required', validate: 'Invalid email' }, | ||
age: { min: 'Age must be at least 18' }, | ||
}; | ||
|
||
const validator = new Validator(rules, messages); | ||
|
||
const data = { email: '[email protected]', age: 20 }; | ||
|
||
validator.validate(data).then(isValid => { | ||
if (isValid) { | ||
console.log('Validation successful'); | ||
} else { | ||
console.log('Validation failed', validator.getErrors()); | ||
} | ||
}); | ||
``` | ||
|
||
## API Reference | ||
|
||
### `Validator(rules, messages, [options])` | ||
|
||
- `rules`: Object containing validation rules. | ||
- `messages`: Corresponding error messages for each rule. | ||
- `options`: Optional settings like strict mode. | ||
|
||
### Methods | ||
|
||
- `validate(input)`: Validates the input against the rules. | ||
- `getErrors()`: Returns validation errors. | ||
- `getPassedFields()`: Returns fields that passed validation. | ||
- `reset()`: Resets the validation state. | ||
|
||
## License | ||
|
||
This project is licensed under the [MIT License](LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "@vmgware/js-validator", | ||
"version": "0.9.0", | ||
"description": "A versatile and easy-to-use JavaScript validation library for ensuring data integrity with extensive customization options.", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/VMGWARE/js-validator.git" | ||
}, | ||
"author": "VMG Ware", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/VMGWARE/js-validator/issues" | ||
}, | ||
"homepage": "https://github.com/VMGWARE/js-validator#readme" | ||
} |
Oops, something went wrong.