Skip to content

Commit 13faab6

Browse files
author
Ben Thinnes
committed
Version 0.0.1
0 parents  commit 13faab6

Some content is hidden

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

49 files changed

+8098
-0
lines changed

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/lib

.eslintrc.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module.exports = {
2+
root: true,
3+
parserOptions: {
4+
parser: 'babel-eslint',
5+
sourceType: 'module'
6+
},
7+
env: {
8+
browser: true
9+
},
10+
extends: [
11+
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
12+
'standard'
13+
],
14+
// add your custom rules here
15+
'rules': {
16+
// allow async-await
17+
'generator-star-spacing': 'off',
18+
19+
// allow paren-less arrow functions
20+
'arrow-parens': 0,
21+
'one-var': 0,
22+
23+
'import/first': 0,
24+
'import/named': 2,
25+
'import/namespace': 2,
26+
'import/default': 2,
27+
'import/export': 2,
28+
'import/extensions': 0,
29+
'import/no-unresolved': 0,
30+
'import/no-extraneous-dependencies': 0,
31+
32+
// allow debugger during development
33+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
34+
}
35+
}

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.DS_Store
2+
.thumbs.db
3+
node_modules
4+
/lib
5+
npm-debug.log*
6+
yarn-debug.log*
7+
yarn-error.log*
8+
9+
# Editor directories and files
10+
.idea
11+
.vscode
12+
*.suo
13+
*.ntvs*
14+
*.njsproj
15+
*.sln

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 m0dch3n
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# JS Validators
2+
3+
## Credits
4+
Credits go to https://github.com/monterail/vuelidate as the functions are taken or inspired from this project, without the vue overhead
5+
6+
## Why this validator collection
7+
8+
The idea is to have a simple javascript validator collection of checks which are often used
9+
10+
## List of current available checks
11+
12+
* alpha
13+
* alphaNum
14+
* numeric
15+
* between
16+
* decimal
17+
* email
18+
* integer
19+
* ipv4Address
20+
* macAddress
21+
* maxLength
22+
* maxValue
23+
* minValue
24+
* minLength
25+
* required
26+
* requiredIf
27+
* requiredUnless
28+
* url
29+
* sameAs
30+
31+
## Usage
32+
33+
``` javascript
34+
import email, between from 'js-validators'
35+
36+
console.log(email.check('[email protected]'))
37+
console.log(email.params)
38+
39+
let between3And6 = between(3,6)
40+
console.log(between3And6.check(10))
41+
console.log(between3And6.params)
42+
43+
```
44+
45+
## Why params ?
46+
47+
Simply because often, validation checks need to be translated to different languages, i.e.
48+
49+
``` javascript
50+
between: 'This field needs to be between {min} and {max}'
51+
```
52+
53+
## Function only, without params
54+
55+
``` javascript
56+
import {check as emailCheck} from 'js-validators/email'
57+
58+
console.log(emailCheck('invalidmail'))
59+
```
60+
## Build & Test
61+
62+
``` bash
63+
# npm run build
64+
# npm run test
65+
```

karma.conf.js

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Karma configuration
2+
// Generated on Thu Mar 22 2018 16:17:49 GMT+0100 (CET)
3+
4+
module.exports = function(config) {
5+
config.set({
6+
7+
// base path that will be used to resolve all patterns (eg. files, exclude)
8+
basePath: '',
9+
10+
11+
// frameworks to use
12+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
13+
frameworks: ['browserify', 'jasmine'],
14+
15+
16+
// list of files / patterns to load in the browser
17+
files: [
18+
'test/**/*spec.js'
19+
],
20+
21+
22+
// list of files / patterns to exclude
23+
exclude: [
24+
],
25+
26+
plugins: [
27+
'karma-browserify',
28+
'karma-chrome-launcher',
29+
'karma-jasmine'
30+
],
31+
32+
// preprocess matching files before serving them to the browser
33+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
34+
preprocessors: {
35+
'src/**/*.js': ['browserify'],
36+
'test/**/*.js': ['browserify']
37+
},
38+
39+
browserify: {
40+
debug: true,
41+
transform: ['babelify']
42+
},
43+
44+
// test results reporter to use
45+
// possible values: 'dots', 'progress'
46+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
47+
reporters: ['progress'],
48+
49+
50+
// web server port
51+
port: 9876,
52+
53+
54+
// enable / disable colors in the output (reporters and logs)
55+
colors: true,
56+
57+
58+
// level of logging
59+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
60+
logLevel: config.LOG_INFO,
61+
62+
63+
// enable / disable watching file and executing tests whenever any file changes
64+
autoWatch: true,
65+
66+
67+
// start these browsers
68+
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
69+
browsers: ['Chrome'],
70+
71+
72+
// Continuous Integration mode
73+
// if true, Karma captures browsers, runs the tests and exits
74+
singleRun: false,
75+
76+
// Concurrency level
77+
// how many browser should be started simultaneous
78+
concurrency: Infinity
79+
})
80+
}

0 commit comments

Comments
 (0)