File tree Expand file tree Collapse file tree 7 files changed +1152
-31
lines changed
Expand file tree Collapse file tree 7 files changed +1152
-31
lines changed Original file line number Diff line number Diff line change 11/node_modules
22/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 11{
22 "name" : " @stackkit/validate" ,
33 "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" ,
57 "repository" :
" [email protected] :stackkit/validate.git" ,
68 "author" :
" larsvankleef <[email protected] >" ,
79 "license" : " MIT" ,
810 "scripts" : {
911 "test" : " jest --coverage" ,
1012 "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"
1215 },
1316 "devDependencies" : {
17+ "@rollup/plugin-commonjs" : " ^14.0.0" ,
18+ "@rollup/plugin-node-resolve" : " ^8.4.0" ,
1419 "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"
1623 }
1724}
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 11function validate ( fields , { rules } ) {
22 const checked = [ ]
33
4- if ( ! fields || ! rules || ! rules . fields ) {
4+ if ( ! fields || ! rules || ! rules . fields ) {
55 return { valid : false , results : [ ] }
66 }
77
8- Object . keys ( rules . fields ) . forEach ( ( field ) => {
8+ Object . keys ( rules . fields ) . forEach ( field => {
99 const value = fields [ field ]
1010 const rule = rules . fields [ field ]
1111
Original file line number Diff line number Diff line change @@ -35,5 +35,5 @@ module.exports = {
3535 email,
3636 length,
3737 number,
38- required
38+ required,
3939}
You can’t perform that action at this time.
0 commit comments