@yutangshi/form-validation

1.1.0 • Public • Published

form-validation

Build Status npm version npm Greenkeeper badge

Validate data fields format in JavaScript

Usage

npm i @yutangshi/form-validation --save
const formValidation = require('formValidation');
const form = new formValidation(); // Get the validation object

// Validate user name input. 驗證姓名不可為數字或特殊符號。
const res = form.userName("Allen");
// response format
// { 
//	status: 200, 
//	message: ""
// }

// Validate mobile input. 驗證手機號碼必須為09開頭且為10碼
const res = form.mobile("001399302");
// response format
// { 
//	status: 512, 
//	message: "您輸入的手機格式不正確。"
// }

// Validate email input. 驗證Email必須包含@符號以及.的網域名稱。
const res = form.email("service@com");
// response format
// { 
//	status: 512, 
//	message: "您輸入Email格式不正確。"
// }

// Validate identity card input of Taiwan. 驗證台灣身分證字號。
const res = form.idcard("11233211");
// response format
// { 
//	status: 512, 
//	message: "您輸入身分證字號格式不正確。"
// }


// Validate credit card input with customize message.
// 驗證信用卡16碼格資料格式,套用客製訊息。
const res = form.creditCard("11-2222-2345-2242","卡號不正確。");
// response format
// { 
//	status: 512, 
//	message: "卡號不正確。"
// }

License

MIT

Package Sidebar

Install

npm i @yutangshi/form-validation

Weekly Downloads

0

Version

1.1.0

License

MIT

Unpacked Size

7.83 kB

Total Files

6

Last publish

Collaborators

  • yutangshi