upcore-tcp 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/checkType.js +15 -0
  2. package/package.json +1 -1
package/lib/checkType.js CHANGED
@@ -68,6 +68,17 @@ function isValidEmail(s){
68
68
 
69
69
  return at > 0 && dot > at + 1 && dot < s.length - 1;
70
70
  }
71
+ function isValidTel(s){
72
+ if (s.length !== 10) return false;
73
+ if (s.charCodeAt(0) !== 48) return false; // '0'
74
+
75
+ for (let i = 0; i < 10; i++) {
76
+ const c = s.charCodeAt(i);
77
+ if (c < 48 || c > 57) return false; // not 0-9
78
+ }
79
+
80
+ return true;
81
+ }
71
82
 
72
83
  module.exports = function({type, length, format, list}, data){
73
84
  let status = false;
@@ -124,6 +135,10 @@ module.exports = function({type, length, format, list}, data){
124
135
  if(isValidEmail(data)){
125
136
  status = true;
126
137
  }
138
+ }else if(format == 'tel'){
139
+ if(isValidTel(data)){
140
+ status = true;
141
+ }
127
142
  }else if(format == 'hex'){
128
143
  if(isValidHex(data)){
129
144
  status = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "upcore-tcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Upcore Web framework support http websocket",
5
5
  "keywords": [
6
6
  "upcore",