0.1.0 • Published 2 years ago

@2345mfe/octopus-validate v0.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

octopus-validate

后台表单校验工具库

技术选型

  • typescript
  • rollup

项目结构介绍

validator                     
├─ dist                     // 构建产物   
│  ├─ demo.html             // 示例     
│  ├─ OcValidate.cjs.js     // 构建cjs模式       
│  ├─ OcValidate.esm.js     // 构建ESM模式  
│  └─ OcValidate.umd.js     // 构建UMD合集模式  
├─ scripts                    
│  └─ publish.js            // npm发版(版本号、包名等控制)  
├─ src                        
│  ├─ strategy                
│  │  ├─ pattern.ts            
│  │  └─ validateStrategy.ts  // 正则类方法 
│  ├─ validate                
│  │  └─ validateValue.ts     // 自定义校验类方法  
│  ├─ validator               
│  │  └─ validator.ts        // 自定义校验库 
│  ├─ index.ts                
│  └─ util.js               // 工具 
├─ package.json             // 配置信息  
├─ README.md                // 介绍
├─ rollup.config.js         // rollup配置
├─ tsconfig.json            // typescript配置  
└─ yarn.lock                // yarn

API

详情见源码

  • OcStrategy 正则类方法
  • OcValidate 自定义校验类方法
  • OcValidator 自定义校验库

包名

  • @2345mfe/octopus-validate

本地开发

npm start

打包

npm run build

安装使用

npm install --save-dev  @2345mfe/octopus-validate

项目中调用

  • vue
//main.js
import { OcStrategy, OcValidate, OcValidator } from '@2345mfe/octopus-validate'
Vue.prototype.$OcStrategy = OcStrategy
Vue.prototype.$OcValidator = OcValidator

// 业务示例 edit.vue
<el-form-item label="曝光总控" :rules="[{ required: false, validator: $OcValidator.checkNumLimit(3,'输出3以内的正整数'), trigger: 'blur' }]" prop="exposure_limit">
      <el-input v-model="ruleForm.exposure_limit" maxlength="40" placeholder="请输入曝光总控"></el-input>
</el-form-item>   
  • 浏览器
<!-- UMD -->
<script src="./OcValidate.umd.js"></script>
<script>
	var validate = window.OcValidate;
	let {OcStrategy, OcValidate, OcValidator} = validate;
	console.log('UMD:', OcStrategy, OcValidate, OcValidator); //object
</script>
  • ESM
//ESM
<script type="module"></script>;
import {OcStrategy, OcValidate, OcValidator} from './OcValidate.esm.js';
// 示例
console.log('ESM:', OcStrategy, OcValidate, OcValidator); //object
/*
 * 校验正数(可含小数、0)
 */
console.log('输出:', OcStrategy.posiInt); // 输出:/^[1-9]\d*$/
console.log('输出:', OcStrategy.posiInt.test(0), OcStrategy.posiInt.test(2)); // false true

rollup配置依赖

 "devDependencies": {
    "@babel/core": "^7.18.2",
    "@babel/preset-env": "^7.18.2",
    "@types/ms": "^0.7.31",
    "babel-plugin-external-helpers": "^6.22.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-latest": "^6.24.1",
    "commander": "^6.2.0",
    "rollup": "^2.74.1",
    "rollup-plugin-babel": "^4.4.0",
    "rollup-plugin-commonjs": "^10.1.0",
    "rollup-plugin-node-resolve": "^5.2.0",
    "rollup-plugin-typescript": "^1.0.1",
    "rollup-plugin-uglify": "^6.0.4",
    "shelljs": "^0.8.4",
    "ts-node": "^9.0.0",
    "tslib": "^2.0.3",
    "typescript": "^4.0.5"
  },
  "dependencies": {
    "@types/lodash-es": "^4.17.3",
    "lodash-es": "^4.17.15"
  }
  

前期准备及落地提效

详情见内部文档

  • 调研
  • 研讨
0.1.0

2 years ago

0.0.56

2 years ago

0.0.55

2 years ago

0.0.54

2 years ago

0.0.53

2 years ago

0.0.52

2 years ago

0.0.51

2 years ago

0.0.50

2 years ago

0.0.49

2 years ago

0.0.47

2 years ago

0.0.46

2 years ago

0.0.45

2 years ago

0.0.44

2 years ago

0.0.43

2 years ago

0.0.42

2 years ago

0.0.41

2 years ago

0.0.40

2 years ago

0.0.39

2 years ago

0.0.38

2 years ago

0.0.37

2 years ago

0.0.36

2 years ago

0.0.35

2 years ago

0.0.34

2 years ago

0.0.33

2 years ago

0.0.32

2 years ago

0.0.31

2 years ago

0.0.30

2 years ago

0.0.29

2 years ago

0.0.28

2 years ago

0.0.27

2 years ago

0.0.26

2 years ago

0.0.25

2 years ago

0.0.24

2 years ago

0.0.23

2 years ago

0.0.22

2 years ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago