File tree 7 files changed +1152
-31
lines changed
7 files changed +1152
-31
lines changed Original file line number Diff line number Diff line change 1
1
/node_modules
2
2
/coverage
3
+ /build
Original file line number Diff line number Diff line change
1
+ .DS_Store
2
+ node_modules
3
+ npm-debug.log
4
+ src /
5
+ * .test.js
6
+ coverage /
7
+ rollup.config.js
8
+ .gitignore
9
+ .prettierrc
10
+ jest.config.js
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @stackkit/validate" ,
3
3
"version" : " 0.0.1" ,
4
- "main" : " src/validate.js" ,
4
+ "main" : " build/index.cjs.js" ,
5
+ "module" : " build/index.esm.js" ,
6
+ "browser" : " build/index.js" ,
5
7
"repository" :
" [email protected] :stackkit/validate.git" ,
6
8
"author" :
" larsvankleef <[email protected] >" ,
7
9
"license" : " MIT" ,
8
10
"scripts" : {
9
11
"test" : " jest --coverage" ,
10
12
"test:watch" : " jest --watch" ,
11
- "test:open" : " open coverage/lcov-report/index.html"
13
+ "test:open" : " open coverage/lcov-report/index.html" ,
14
+ "build" : " npx rollup -c"
12
15
},
13
16
"devDependencies" : {
17
+ "@rollup/plugin-commonjs" : " ^14.0.0" ,
18
+ "@rollup/plugin-node-resolve" : " ^8.4.0" ,
14
19
"jest" : " ^26.2.2" ,
15
- "prettier" : " ^2.0.5"
20
+ "prettier" : " ^2.0.5" ,
21
+ "rollup" : " ^2.23.1" ,
22
+ "rollup-plugin-filesize" : " ^9.0.2"
16
23
}
17
24
}
Original file line number Diff line number Diff line change
1
+
2
+ import resolve from '@rollup/plugin-node-resolve' ;
3
+ import commonjs from '@rollup/plugin-commonjs' ;
4
+ import filesize from 'rollup-plugin-filesize' ;
5
+
6
+ import pkg from './package.json' ;
7
+
8
+ const INPUT_FILE_PATH = 'src/index.js' ;
9
+ const OUTPUT_NAME = 'Example' ;
10
+
11
+ const PLUGINS = [
12
+ resolve ( {
13
+ browser : true ,
14
+ } ) ,
15
+ commonjs ( ) ,
16
+ filesize ( ) ,
17
+ ] ;
18
+
19
+ const OUTPUT_DATA = [
20
+ {
21
+ file : pkg . browser ,
22
+ format : 'umd' ,
23
+ } ,
24
+ {
25
+ file : pkg . main ,
26
+ format : 'cjs' ,
27
+ } ,
28
+ {
29
+ file : pkg . module ,
30
+ format : 'es' ,
31
+ } ,
32
+ ] ;
33
+
34
+ const config = OUTPUT_DATA . map ( ( { file, format } ) => ( {
35
+ input : INPUT_FILE_PATH ,
36
+ output : {
37
+ file,
38
+ format,
39
+ name : OUTPUT_NAME ,
40
+ exports : 'default'
41
+ } ,
42
+ plugins : PLUGINS ,
43
+ } ) ) ;
44
+
45
+ export default config ;
Original file line number Diff line number Diff line change 1
1
function validate ( fields , { rules } ) {
2
2
const checked = [ ]
3
3
4
- if ( ! fields || ! rules || ! rules . fields ) {
4
+ if ( ! fields || ! rules || ! rules . fields ) {
5
5
return { valid : false , results : [ ] }
6
6
}
7
7
8
- Object . keys ( rules . fields ) . forEach ( ( field ) => {
8
+ Object . keys ( rules . fields ) . forEach ( field => {
9
9
const value = fields [ field ]
10
10
const rule = rules . fields [ field ]
11
11
Original file line number Diff line number Diff line change @@ -35,5 +35,5 @@ module.exports = {
35
35
email,
36
36
length,
37
37
number,
38
- required
38
+ required,
39
39
}
You can’t perform that action at this time.
0 commit comments