Skip to content

Commit 264e54f

Browse files
committed
first commit
1 parent 126be38 commit 264e54f

File tree

126 files changed

+8814
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+8814
-0
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
[*]
7+
indent_style = tab
8+
indent_size = 2
9+
end_of_line = lf
10+
charset = utf-8
11+
trim_trailing_whitespace = true
12+
insert_final_newline = true

.eslintignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
dist/
2+
node_modules/
3+
tests/**/*
4+
types/
5+
webpack.config.js
6+
jestTestFile.js
7+
BackupCopia
8+
.eslintrc.js

.eslintrc.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
module.exports = {
2+
extends: [
3+
"eslint:recommended",
4+
"plugin:@typescript-eslint/strict-type-checked",
5+
"plugin:prettier/recommended",
6+
],
7+
parser: "@typescript-eslint/parser",
8+
parserOptions: {
9+
project: true,
10+
tsconfigRootDir: __dirname,
11+
},
12+
plugins: ["@typescript-eslint"],
13+
root: true,
14+
rules: {
15+
"no-else-return": ["error", { allowElseIf: false }],
16+
"consistent-return": "error",
17+
"no-console": ["warn", { allow: ["warn", "error"] }], // Here you are allowing console.warn and console.error
18+
"@typescript-eslint/typedef": [
19+
"error",
20+
{
21+
variableDeclaration: true,
22+
memberVariableDeclaration: true,
23+
},
24+
],
25+
"@typescript-eslint/explicit-module-boundary-types": "error",
26+
"@typescript-eslint/naming-convention": [
27+
"error",
28+
{
29+
selector: "class",
30+
format: ["PascalCase"],
31+
},
32+
],
33+
"@typescript-eslint/prefer-readonly": "error",
34+
"@typescript-eslint/explicit-member-accessibility": [
35+
"error",
36+
{
37+
accessibility: "explicit",
38+
overrides: {
39+
accessors: "explicit",
40+
constructors: "no-public",
41+
methods: "explicit",
42+
properties: "explicit",
43+
parameterProperties: "explicit",
44+
},
45+
},
46+
],
47+
},
48+
};

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
coverage
2+
node_modules/
3+
BackupCopia/
4+
todo.txt
5+
teste.html
6+
dist
7+
types

.npmignore

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Ignora o .gitignore
2+
.gitignore
3+
4+
# Ignora o .eslintrc.js
5+
.eslintrc.js
6+
7+
# Ignora o .editorconfig
8+
.editorconfig
9+
10+
# Ignora todos os arquivos de código-fonte, exceto .js e ts
11+
*.java
12+
*.py
13+
*.cpp
14+
*.c
15+
*.h
16+
*.php
17+
*.html
18+
*.htm
19+
*.xml
20+
*.css
21+
*.scss
22+
*.sass
23+
# Adicione aqui outros tipos de arquivos de código-fonte que você queira ignorar
24+
.htaccess
25+
srcPage/
26+
Backup/
27+
BackupCopia/
28+
tsconfig.json
29+
pythonVersion/
30+
javaVersion/
31+
phpVersion/
32+
cSharpVersion/
33+
tester.js
34+
/src
35+
index.ts
36+
.vscode/
37+
composer.json
38+
tests/
39+
jest.config.js
40+
images/
41+
.npmignore
42+
package-lock.json
43+
coverage/
44+
tsconfig.types.json
45+
.eslintignore
46+
.prettierrc.js
47+
.prettierrc
48+
.prettierignore
49+
todo.txt
50+
webpack.config.js
51+
gitpush
52+
gitpush.exe
53+
jestTestFile.js

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist
2+
node_modules
3+
coverage

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"code-runner.executorMap": {
3+
"typescript": "npx ts-node",
4+
},
5+
}

README.md

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
> [!NOTE]
2+
> I accept help to make the version of the other programming languages.
3+
4+
# Multiform-validator
5+
6+
[![npm version](https://badge.fury.io/js/multiform-validator.svg)](https://badge.fury.io/js/multiform-validator)
7+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8+
[![npm downloads](https://img.shields.io/npm/dm/multiform-validator.svg?style=flat-square)](https://npm-stat.com/charts.html?package=multiform-validator)
9+
10+
This npm package provides JavaScript functions to validate various forms fields.
11+
12+
Documentation: https://multiform-validator.vercel.app
13+
14+
Feel free to find bugs and report them to me. Your feedback is highly appreciated. Hugs from Gabriel Logan!
15+
16+
## CDNs
17+
18+
jsDelivr:
19+
```bash
20+
https://cdn.jsdelivr.net/npm/[email protected]/dist/bundle.min.js
21+
```
22+
```html
23+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/bundle.min.js"></script>
24+
```
25+
26+
unpkg:
27+
```bash
28+
https://unpkg.com/[email protected]/dist/bundle.js
29+
```
30+
```html
31+
<script src="https://unpkg.com/[email protected]/dist/bundle.js"></script>
32+
```
33+
34+
### Example of use with CDN
35+
36+
```html
37+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/bundle.min.js"></script>
38+
<script>
39+
40+
const emailResult = isEmail('123456');
41+
const cpfResult = cpfIsValid('123456');
42+
43+
console.log(emailResult); // returns false
44+
console.log(cpfResult.isValid); // returns false
45+
46+
</script>
47+
```
48+
49+
## Installation
50+
51+
```bash
52+
npm install multiform-validator
53+
```
54+
55+
or
56+
57+
```bash
58+
yarn add multiform-validator
59+
```
60+
61+
## Data Validator
62+
63+
This package contains various modules for validating different types of data. Below are the available validation modules:
64+
65+
## Available Validation Modules
66+
67+
- **cnpjValidator**: CNPJ validation.
68+
- **cpfValidator**: CPF validation.
69+
- **getOnlyEmail**: Extracts only the email or emails address from a string.
70+
- **identifyFlagCard**: Identifies the flag of a credit card.
71+
- **isAscii**: Checks if the string contains only ASCII characters.
72+
- **isBase64**: Checks if the string is a valid Base64 encoding.
73+
- **isCEP**: CEP validation (Brazilian postal code).
74+
- **isCreditCardValid**: Credit card validation.
75+
- **isDate**: Date format validation.
76+
- **isDecimal**: Checks if the number is a decimal.
77+
- **isEmail**: Email address validation format.
78+
- **isEmpty**: Checks if the string is empty.
79+
- **isMACAddress**: MAC address validation.
80+
- **isMD5**: Checks if the string is a valid MD5 hash.
81+
- **isNumber**: Checks if the value is a number.
82+
- **isPort**: Port number validation.
83+
- **isPostalCode**: Postal code validation.
84+
- **isTime**: Time format validation.
85+
- **isValidAudio**: Audio file validation.
86+
- **isValidImage**: Image file validation.
87+
- **isValidPdf**: Pdf file validation.
88+
- **isValidTxt**: Txt file validation.
89+
- **isValidVideo**: Video file validation.
90+
- **passwordStrengthTester**: Password strength test.
91+
- **validateBRPhoneNumber**: Brazilian phone number validation.
92+
- **validateEmail**: Email address full validation.
93+
- **validateName**: Name validation.
94+
- **validatePassword**: Password validation.
95+
- **validatePassportNumber**: Passport number validation.
96+
- **validatePhoneNumber**: Phone number validation.
97+
- **validateSurname**: Surname validation.
98+
- **validateTextarea**: Textarea validation.
99+
- **validateUsername**: Username validation.
100+
- **validateUSPhoneNumber**: US phone number validation.
101+
102+
### You can use it in React Native, Angular, any javascript framework or any javascript or typescript code.
103+
#### Example using Reactjs:
104+
105+
![Example using Reactjs](https://raw.githubusercontent.com/gabriel-logan/multiform-validator/main/docs/images/exampleWithReactjs.png)
106+
![Showing error options](https://raw.githubusercontent.com/gabriel-logan/multiform-validator/main/docs/images/options.png)
107+
![Showing error in browser](https://raw.githubusercontent.com/gabriel-logan/multiform-validator/main/docs/images/showErro.png)
108+
109+
### For better information, read the documentation
110+
111+
```javascript
112+
113+
const validator = require('multiform-validator');
114+
// or
115+
import validator from 'multiform-validator';
116+
117+
or
118+
119+
// Attention, FUNCTION_NAME is not a valid function name! It is just an example of how to import the functions.
120+
121+
const { FUNCTION_NAME } = require('multiform-validator');
122+
// or
123+
import { FUNCTION_NAME } from 'multiform-validator';
124+
125+
```
126+
127+
```javascript
128+
129+
const validator = require('multiform-validator');
130+
// or
131+
import validator from 'multiform-validator';
132+
// then
133+
validator.FUNCTION_NAME
134+
// OBS: 'if the function is called validate, the return will be an object and not boolean'
135+
// When return object boolean
136+
validator.FUNCTION_NAME = true or false
137+
// When return object
138+
validator.FUNCTION_NAME = object = { isValid: true or false, errorMsg: 'stringError' }
139+
validator.FUNCTION_NAME.isValid = true or false
140+
validator.FUNCTION_NAME.errorMsg = 'ErrorMsg' // You can customize errors
141+
/**
142+
* There are other returns in some functions, with strings etc, stay tuned
143+
*/
144+
```
145+
146+
## Documentation
147+
### https://multiform-validator.vercel.app
148+
149+
```javascript
150+
151+
const { validateEmail } = require('multiform-validator');
152+
// or
153+
import { validateEmail } from 'multiform-validator';
154+
155+
// It has many more validations, you can read the documentation or
156+
// do several tests to learn how to use the library in the best possible way.
157+
158+
// Two last parameters are optional
159+
console.log(validateEmail('[email protected]', { maxLength: 30, country: 'br' }).isValid); // returns false
160+
console.log(validateEmail('[email protected]', { maxLength: 30, country: 'br' }).isValid); // returns true
161+
console.log(validateEmail('[email protected]', { maxLength: 30 }).isValid); // returns true
162+
163+
// All examples return default messages, below is an example setting your own messages
164+
165+
// If you want to use a default parameter, use null.
166+
167+
const validationResult = validateEmail('[email protected]', { maxLength: 30 });
168+
169+
if (validationResult.isValid) {
170+
console.log('0 errors');
171+
} else {
172+
console.log(validationResult.errorMsg); // returns the error
173+
}
174+
175+
// or
176+
177+
const validationResult = validateEmail("[email protected]", {
178+
maxLength: 30,
179+
errorMsg: [null, "This is an invalid email with my own errors"],
180+
});
181+
182+
if (validationResult.isValid) {
183+
console.log('0 errors');
184+
} else {
185+
console.log(validationResult.errorMsg); // Return 'This is an invalid email with my own errors'
186+
}
187+
188+
```
189+
190+
Feel free to explore the various functions and experiment with different inputs to understand their behavior. If you encounter any issues or have suggestions, don't hesitate to reach out to me. Your feedback is valuable and helps improve the package. Happy coding!
191+
192+
If you want to help me, you can buy me a coffee (:
193+
194+
<p align="center">
195+
<a href="https://www.buymeacoffee.com/gabriellogan" target="_blank">
196+
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" >
197+
</a>
198+
</p>
199+
200+
# By - Gabriel Logan

0 commit comments

Comments
 (0)