@unicom-cloud/utils 0.1.31 → 0.1.33

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 (369) hide show
  1. package/case-name/index.js +1 -1
  2. package/caseName.js +1 -1
  3. package/class-name/index.js +6 -5
  4. package/className.js +1 -1
  5. package/clipboard-copy/index.js +1 -1
  6. package/clipboardCopy.js +1 -1
  7. package/constant/address.js +1 -1
  8. package/constant/chineseCharacters.js +1 -1
  9. package/constant/constellations.js +1 -1
  10. package/constant/domain.js +1 -1
  11. package/constant/emoji.js +1 -1
  12. package/constant/identity.js +1 -1
  13. package/constant/index.js +1 -1
  14. package/constant/isMobile.js +7 -0
  15. package/constant/keyboardCode.js +1 -1
  16. package/constant/licensePlate.js +1 -1
  17. package/constant/name.js +1 -1
  18. package/constant/platform.js +18 -17
  19. package/constant/protocol.js +1 -1
  20. package/constant/string.js +1 -1
  21. package/constant/ui.js +1 -1
  22. package/constant.js +1 -1
  23. package/content-disposition/index.js +1 -1
  24. package/contentDisposition.js +1 -1
  25. package/cookie/index.js +1 -1
  26. package/cookie/src/api.js +1 -1
  27. package/cookie/src/assign.js +1 -1
  28. package/cookie/src/converter.js +1 -1
  29. package/cookie.js +1 -1
  30. package/date/convertTime.js +1 -1
  31. package/date/convertToDuration.js +1 -1
  32. package/date/index.js +5 -5
  33. package/date.js +5 -5
  34. package/decimal/decimal.js +1 -1
  35. package/decimal/index.js +1 -1
  36. package/decimal.js +1 -1
  37. package/dom-helpers/activeElement.js +1 -1
  38. package/dom-helpers/addClass.js +1 -1
  39. package/dom-helpers/addEventListener.js +1 -1
  40. package/dom-helpers/animate.js +1 -1
  41. package/dom-helpers/animationFrame.js +1 -1
  42. package/dom-helpers/attribute.js +1 -1
  43. package/dom-helpers/camelize.js +1 -1
  44. package/dom-helpers/camelizeStyle.js +1 -1
  45. package/dom-helpers/canUseDOM.js +1 -1
  46. package/dom-helpers/childElements.js +1 -1
  47. package/dom-helpers/childNodes.js +1 -1
  48. package/dom-helpers/clear.js +1 -1
  49. package/dom-helpers/closest.js +1 -1
  50. package/dom-helpers/collectElements.js +1 -1
  51. package/dom-helpers/collectSiblings.js +1 -1
  52. package/dom-helpers/contains.js +1 -1
  53. package/dom-helpers/css.js +1 -1
  54. package/dom-helpers/filterEventHandler.js +1 -1
  55. package/dom-helpers/getComputedStyle.js +1 -1
  56. package/dom-helpers/getElementCoordinates.js +46 -0
  57. package/dom-helpers/getScrollAccessor.js +1 -1
  58. package/dom-helpers/hasClass.js +1 -1
  59. package/dom-helpers/height.js +1 -1
  60. package/dom-helpers/hyphenate.js +1 -1
  61. package/dom-helpers/hyphenateStyle.js +1 -1
  62. package/dom-helpers/index.js +87 -84
  63. package/dom-helpers/insertAfter.js +1 -1
  64. package/dom-helpers/isDocument.js +1 -1
  65. package/dom-helpers/isInput.js +1 -1
  66. package/dom-helpers/isTransform.js +1 -1
  67. package/dom-helpers/isVisible.js +1 -1
  68. package/dom-helpers/isWindow.js +1 -1
  69. package/dom-helpers/listen.js +1 -1
  70. package/dom-helpers/matches.js +1 -1
  71. package/dom-helpers/nextUntil.js +1 -1
  72. package/dom-helpers/offset.js +1 -1
  73. package/dom-helpers/offsetParent.js +1 -1
  74. package/dom-helpers/ownerDocument.js +1 -1
  75. package/dom-helpers/ownerWindow.js +1 -1
  76. package/dom-helpers/parents.js +1 -1
  77. package/dom-helpers/position.js +1 -1
  78. package/dom-helpers/prepend.js +1 -1
  79. package/dom-helpers/querySelectorAll.js +1 -1
  80. package/dom-helpers/reflow.js +1 -1
  81. package/dom-helpers/remove.js +1 -1
  82. package/dom-helpers/removeClass.js +1 -1
  83. package/dom-helpers/removeEventListener.js +1 -1
  84. package/dom-helpers/scrollLeft.js +1 -1
  85. package/dom-helpers/scrollParent.js +1 -1
  86. package/dom-helpers/scrollTo.js +1 -1
  87. package/dom-helpers/scrollTop.js +1 -1
  88. package/dom-helpers/scrollbarSize.js +1 -1
  89. package/dom-helpers/siblings.js +1 -1
  90. package/dom-helpers/text.js +1 -1
  91. package/dom-helpers/toggleClass.js +1 -1
  92. package/dom-helpers/transitionEnd.js +2 -2
  93. package/dom-helpers/triggerEvent.js +1 -1
  94. package/dom-helpers/types.js +1 -1
  95. package/dom-helpers/width.js +1 -1
  96. package/domHelpers.js +65 -63
  97. package/emitter/index.js +1 -1
  98. package/emitter/src/index.js +1 -1
  99. package/emitter.js +1 -1
  100. package/escape/index.js +11 -0
  101. package/escape.js +6 -0
  102. package/file/fileToURL.js +1 -1
  103. package/file/index.js +1 -1
  104. package/file/saveAs.js +1 -1
  105. package/file.js +1 -1
  106. package/idb/index.js +1 -1
  107. package/idb.js +1 -1
  108. package/index.js +1 -1
  109. package/invariant/index.js +1 -1
  110. package/invariant.js +1 -1
  111. package/is/index.js +196 -141
  112. package/is/lib/isAscii.js +9 -0
  113. package/is/lib/isBase64.js +13 -0
  114. package/is/lib/isChinese.js +19 -0
  115. package/is/lib/isDataURI.js +25 -0
  116. package/is/lib/isEmail.js +72 -0
  117. package/is/lib/isFQDN.js +21 -0
  118. package/is/lib/isFullWidth.js +10 -0
  119. package/is/lib/isHSL.js +11 -0
  120. package/is/lib/isHalfWidth.js +10 -0
  121. package/is/lib/isHash.js +23 -0
  122. package/is/lib/isHexColor.js +12 -0
  123. package/is/lib/isIMEI.js +19 -0
  124. package/is/lib/isIP.js +21 -0
  125. package/is/lib/isIPRange.js +25 -0
  126. package/is/lib/isIdentityCard.js +190 -0
  127. package/is/lib/isJWT.js +14 -0
  128. package/is/lib/isMACAddress.js +9 -0
  129. package/is/lib/isMD5.js +9 -0
  130. package/is/lib/isMimeType.js +9 -0
  131. package/is/lib/isMobilePhone.js +192 -0
  132. package/is/lib/isPort.js +7 -0
  133. package/is/lib/isRgbColor.js +18 -0
  134. package/is/lib/isSemVer.js +20 -0
  135. package/is/lib/isSlug.js +9 -0
  136. package/is/lib/isStrongPassword.js +48 -0
  137. package/is/lib/isURL.js +78 -0
  138. package/is/lib/isUUID.js +24 -0
  139. package/is/lib/isVariableWidth.js +10 -0
  140. package/is/lib/util/assertString.js +12 -0
  141. package/is.js +122 -66
  142. package/lunar/index.js +1 -1
  143. package/lunar/lib/Holiday.js +1 -1
  144. package/lunar/lib/HolidayUtil.js +1 -1
  145. package/lunar/lib/I18n.js +1 -1
  146. package/lunar/lib/JieQi.js +1 -1
  147. package/lunar/lib/Lunar.js +1 -1
  148. package/lunar/lib/LunarMonth.js +1 -1
  149. package/lunar/lib/LunarTime.js +1 -1
  150. package/lunar/lib/LunarUtil.js +1 -1
  151. package/lunar/lib/LunarYear.js +1 -1
  152. package/lunar/lib/ShouXingUtil.js +1 -1
  153. package/lunar/lib/Solar.js +1 -1
  154. package/lunar/lib/SolarHalfYear.js +1 -1
  155. package/lunar/lib/SolarMonth.js +1 -1
  156. package/lunar/lib/SolarSeason.js +1 -1
  157. package/lunar/lib/SolarUtil.js +1 -1
  158. package/lunar/lib/SolarWeek.js +1 -1
  159. package/lunar/lib/SolarYear.js +1 -1
  160. package/lunar/lib/index.js +1 -1
  161. package/lunar.js +1 -1
  162. package/math/index.js +1 -1
  163. package/math.js +1 -1
  164. package/md5/index.js +1 -1
  165. package/md5.js +1 -1
  166. package/mock/MockWebSocket.js +1 -1
  167. package/mock/MockXMLHttpRequest.js +1 -1
  168. package/mock/index.js +1 -1
  169. package/mock.js +1 -1
  170. package/normalize-wheel/ExecutionEnvironment.js +1 -1
  171. package/normalize-wheel/UserAgent_DEPRECATED.js +1 -1
  172. package/normalize-wheel/index.js +1 -1
  173. package/normalize-wheel/isEventSupported.js +1 -1
  174. package/normalizeWheel.js +1 -1
  175. package/number-to-chinese/index.js +1 -1
  176. package/numberToChinese.js +1 -1
  177. package/nzh/cn.js +1 -1
  178. package/nzh/hk.js +1 -1
  179. package/nzh/index.js +1 -1
  180. package/nzh/nzh.js +1 -1
  181. package/nzh/src/autoGet.js +1 -1
  182. package/nzh/src/index.js +1 -1
  183. package/nzh/src/langs/cn_b.js +1 -1
  184. package/nzh/src/langs/cn_s.js +1 -1
  185. package/nzh/src/langs/hk_b.js +1 -1
  186. package/nzh/src/langs/hk_s.js +1 -1
  187. package/nzh/src/utils.js +1 -1
  188. package/nzh.js +1 -1
  189. package/object-keys-sort/index.js +1 -1
  190. package/object-prototype-to-string-call/index.js +2 -2
  191. package/objectKeysSort.js +1 -1
  192. package/objectPrototypeToStringCall.js +1 -1
  193. package/package.json +1 -1
  194. package/pinyin/index.js +1 -1
  195. package/pinyin/simplified.js +1 -1
  196. package/pinyin/src/core.js +1 -1
  197. package/pinyin/src/simplified.js +6 -6
  198. package/pinyin/src/simplified_dict.js +5 -4
  199. package/pinyin/src/traditional.js +4 -4
  200. package/pinyin/src/traditional_dict.js +4 -3
  201. package/pinyin/traditional.js +1 -1
  202. package/pinyin.js +1 -1
  203. package/query-string/base.js +1 -1
  204. package/query-string/index.js +1 -1
  205. package/query-string/splitOnFirst.js +1 -1
  206. package/queryString.js +1 -1
  207. package/random/address.js +1 -1
  208. package/random/constellation.js +1 -1
  209. package/random/image.js +1 -1
  210. package/random/index.js +1 -1
  211. package/random/licensePlate.js +1 -1
  212. package/random/name.js +1 -1
  213. package/random/number.js +1 -1
  214. package/random/text.js +1 -1
  215. package/random/time.js +1 -1
  216. package/random/web.js +1 -1
  217. package/random.js +1 -1
  218. package/screenfull/index.js +1 -1
  219. package/screenfull.js +1 -1
  220. package/sleep/index.js +1 -1
  221. package/sleep.js +1 -1
  222. package/snapdom/index.js +1 -1
  223. package/snapdom/src/api/preCache.js +1 -1
  224. package/snapdom/src/api/snapdom.js +198 -153
  225. package/snapdom/src/core/cache.js +1 -1
  226. package/snapdom/src/core/capture.js +121 -326
  227. package/snapdom/src/core/clone.js +117 -266
  228. package/snapdom/src/core/context.js +1 -1
  229. package/snapdom/src/core/plugins.js +1 -1
  230. package/snapdom/src/core/prepare.js +48 -157
  231. package/snapdom/src/exporters/download.js +15 -11
  232. package/snapdom/src/exporters/toBlob.js +10 -15
  233. package/snapdom/src/exporters/toCanvas.js +72 -65
  234. package/snapdom/src/exporters/toImg.js +1 -1
  235. package/snapdom/src/modules/CSSVar.js +1 -1
  236. package/snapdom/src/modules/background.js +1 -1
  237. package/snapdom/src/modules/changeCSS.js +1 -1
  238. package/snapdom/src/modules/counter.js +1 -1
  239. package/snapdom/src/modules/fonts.js +118 -112
  240. package/snapdom/src/modules/iconFonts.js +133 -69
  241. package/snapdom/src/modules/images.js +36 -33
  242. package/snapdom/src/modules/lineClamp.js +1 -1
  243. package/snapdom/src/modules/pseudo.js +275 -161
  244. package/snapdom/src/modules/rasterize.js +6 -7
  245. package/snapdom/src/modules/snapFetch.js +1 -1
  246. package/snapdom/src/modules/styles.js +89 -67
  247. package/snapdom/src/modules/svgDefs.js +73 -60
  248. package/snapdom/src/utils/browser.js +13 -8
  249. package/snapdom/src/utils/capture.helpers.js +131 -0
  250. package/snapdom/src/utils/clone.helpers.js +283 -0
  251. package/snapdom/src/utils/css.js +1 -1
  252. package/snapdom/src/utils/helpers.js +1 -1
  253. package/snapdom/src/utils/image.js +15 -24
  254. package/snapdom/src/utils/prepare.helpers.js +8 -0
  255. package/snapdom/src/utils/transforms.helpers.js +211 -0
  256. package/snapdom.js +1 -1
  257. package/string/index.js +1 -1
  258. package/string.js +1 -1
  259. package/tinycolor/index.js +1 -1
  260. package/tinycolor/src/conversion.js +1 -1
  261. package/tinycolor/src/css-color-names.js +1 -1
  262. package/tinycolor/src/format-input.js +1 -1
  263. package/tinycolor/src/from-ratio.js +12 -11
  264. package/tinycolor/src/index.js +1 -1
  265. package/tinycolor/src/random.js +30 -29
  266. package/tinycolor/src/readability.js +1 -1
  267. package/tinycolor/src/to-ms-filter.js +1 -1
  268. package/tinycolor/src/utils.js +1 -1
  269. package/tinycolor.js +1 -1
  270. package/tree/index.js +54 -75
  271. package/tree/search/index.js +1 -1
  272. package/tree.js +9 -11
  273. package/tween/index.js +1 -1
  274. package/tween/src/easing.js +1 -1
  275. package/tween/src/tween.js +15 -14
  276. package/tween.js +1 -1
  277. package/types/constant/isMobile.d.ts +3 -0
  278. package/types/date/index.d.ts +3 -3
  279. package/types/dom-helpers/getElementCoordinates.d.ts +40 -0
  280. package/types/dom-helpers/index.d.ts +3 -1
  281. package/types/escape/index.d.ts +2 -0
  282. package/types/is/index.d.ts +28 -1
  283. package/types/is/lib/isAscii.d.ts +1 -0
  284. package/types/is/lib/isBase64.d.ts +1 -0
  285. package/types/is/lib/isChinese.d.ts +4 -0
  286. package/types/is/lib/isDataURI.d.ts +1 -0
  287. package/types/is/lib/isEmail.d.ts +1 -0
  288. package/types/is/lib/isFQDN.d.ts +1 -0
  289. package/types/is/lib/isFullWidth.d.ts +2 -0
  290. package/types/is/lib/isHSL.d.ts +1 -0
  291. package/types/is/lib/isHalfWidth.d.ts +2 -0
  292. package/types/is/lib/isHash.d.ts +1 -0
  293. package/types/is/lib/isHexColor.d.ts +1 -0
  294. package/types/is/lib/isIMEI.d.ts +1 -0
  295. package/types/is/lib/isIP.d.ts +1 -0
  296. package/types/is/lib/isIPRange.d.ts +1 -0
  297. package/types/is/lib/isIdentityCard.d.ts +1 -0
  298. package/types/is/lib/isJWT.d.ts +1 -0
  299. package/types/is/lib/isMACAddress.d.ts +1 -0
  300. package/types/is/lib/isMD5.d.ts +1 -0
  301. package/types/is/lib/isMimeType.d.ts +1 -0
  302. package/types/is/lib/isMobilePhone.d.ts +2 -0
  303. package/types/is/lib/isOctal.d.ts +1 -0
  304. package/types/is/lib/isPort.d.ts +1 -0
  305. package/types/is/lib/isRgbColor.d.ts +1 -0
  306. package/types/is/lib/isSemVer.d.ts +1 -0
  307. package/types/is/lib/isSlug.d.ts +1 -0
  308. package/types/is/lib/isStrongPassword.d.ts +1 -0
  309. package/types/is/lib/isURL.d.ts +1 -0
  310. package/types/is/lib/isUUID.d.ts +1 -0
  311. package/types/is/lib/isVariableWidth.d.ts +1 -0
  312. package/types/is/lib/util/assertString.d.ts +1 -0
  313. package/types/pinyin/es/main.d.ts +4 -0
  314. package/types/pinyin/es/traditional.d.ts +4 -0
  315. package/types/snapdom/src/api/snapdom.d.ts +11 -79
  316. package/types/snapdom/src/exporters/toCanvas.d.ts +11 -3
  317. package/types/snapdom/src/exporters/toJpg.d.ts +1 -0
  318. package/types/snapdom/src/exporters/toPng.d.ts +6 -0
  319. package/types/snapdom/src/exporters/toSvg.d.ts +1 -0
  320. package/types/snapdom/src/exporters/toWebp.d.ts +1 -0
  321. package/types/snapdom/src/modules/iconFonts.d.ts +7 -20
  322. package/types/snapdom/src/modules/pseudo.d.ts +18 -0
  323. package/types/snapdom/src/modules/rasterize.d.ts +6 -10
  324. package/types/snapdom/src/utils/browser.d.ts +0 -3
  325. package/types/snapdom/src/utils/capture.helpers.d.ts +45 -0
  326. package/types/snapdom/src/utils/clone.helpers.d.ts +97 -0
  327. package/types/snapdom/src/utils/image.d.ts +0 -8
  328. package/types/snapdom/src/utils/index.d.ts +1 -1
  329. package/types/snapdom/src/utils/prepare.helpers.d.ts +9 -0
  330. package/types/snapdom/src/utils/transforms.helpers.d.ts +118 -0
  331. package/types/tree/index.d.ts +3 -4
  332. package/types/validate/src/index.d.ts +23 -25
  333. package/types/validate/src/interface.d.ts +5 -3
  334. package/types/validate/src/locale/en-US.d.ts +12 -2
  335. package/types/validate/src/locale/index.d.ts +171 -0
  336. package/types/validate/src/locale/zh-CN.d.ts +12 -2
  337. package/types/validate/src/rules/base.d.ts +3 -1
  338. package/types/validate/src/rules/custom.d.ts +1 -1
  339. package/types/validate/src/rules/type.d.ts +10 -0
  340. package/ui-color/compareColorByRange.js +1 -1
  341. package/ui-color/index.js +8 -7
  342. package/uiColor.js +25 -24
  343. package/url-toolkit/index.js +1 -1
  344. package/url-toolkit/src/url-toolkit.js +1 -1
  345. package/urlToolkit.js +1 -1
  346. package/validate/index.js +23 -25
  347. package/validate/src/index.js +116 -73
  348. package/validate/src/locale/en-US.js +12 -2
  349. package/validate/src/locale/index.js +11 -0
  350. package/validate/src/locale/zh-CN.js +12 -2
  351. package/validate/src/rules/array.js +2 -2
  352. package/validate/src/rules/base.js +35 -31
  353. package/validate/src/rules/boolean.js +1 -1
  354. package/validate/src/rules/custom.js +2 -2
  355. package/validate/src/rules/number.js +1 -1
  356. package/validate/src/rules/object.js +1 -1
  357. package/validate/src/rules/string.js +6 -5
  358. package/validate/src/rules/type.js +84 -14
  359. package/validate.js +23 -25
  360. package/version/index.js +1 -1
  361. package/version.js +1 -1
  362. package/xlsx/index.d.ts +4 -8
  363. package/xlsx/index.js +1 -1
  364. package/xlsx/xlsx.js +2 -2
  365. package/xlsx.js +1 -1
  366. package/types/validate/src/message.d.ts +0 -2
  367. package/types/validate/src/utils.d.ts +0 -3
  368. package/validate/src/message.js +0 -5
  369. package/validate/src/utils.js +0 -8
@@ -1,106 +1,149 @@
1
- /* 2025-11-19 10:03:21 */
2
- import V from "lodash/defaultsDeep";
1
+ /* 2025-12-17 18:26:57 */
2
+ import g from "lodash/defaultsDeep.js";
3
3
  import u from "lodash/isArray.js";
4
- import E from "lodash/isFunction.js";
5
- import v from "lodash/isObjectLike.js";
4
+ import v from "lodash/isFunction.js";
5
+ import V from "lodash/isObjectLike.js";
6
+ import w from "lodash/isUndefined.js";
6
7
  import C from "./rules/array.js";
7
- import M from "./rules/boolean.js";
8
+ import "lodash/get.js";
9
+ import "lodash/isObject.js";
10
+ import "lodash/isString.js";
11
+ import "lodash/isArguments.js";
12
+ import "lodash/isArrayBuffer.js";
13
+ import "lodash/isArrayLike.js";
14
+ import "lodash/isArrayLikeObject.js";
15
+ import "lodash/isBoolean.js";
16
+ import "lodash/isBuffer.js";
17
+ import "lodash/isDate.js";
18
+ import "lodash/isElement.js";
19
+ import "lodash/isEmpty.js";
20
+ import "lodash/isEqual.js";
21
+ import "lodash/isEqualWith.js";
22
+ import "lodash/isError.js";
23
+ import "lodash/isFinite.js";
24
+ import "lodash/isInteger.js";
25
+ import "lodash/isLength.js";
26
+ import "lodash/isMap.js";
27
+ import "lodash/isMatch.js";
28
+ import "lodash/isMatchWith.js";
29
+ import "lodash/isNaN.js";
30
+ import "lodash/isNative.js";
31
+ import "lodash/isNil.js";
32
+ import "lodash/isNull.js";
33
+ import "lodash/isNumber.js";
34
+ import "lodash/isPlainObject.js";
35
+ import "lodash/isRegExp.js";
36
+ import "lodash/isSafeInteger.js";
37
+ import "lodash/isSet.js";
38
+ import "lodash/isSymbol.js";
39
+ import "lodash/isTypedArray.js";
40
+ import "lodash/isWeakMap.js";
41
+ import "lodash/isWeakSet.js";
42
+ import "lodash/isNil";
43
+ import "lodash/defaults";
44
+ import "lodash/isObject";
45
+ import "lodash/isUndefined";
46
+ import "../../is/lib/isMobilePhone.js";
47
+ import "lodash/isString";
48
+ import E from "./rules/boolean.js";
8
49
  import S from "./rules/custom.js";
9
- import q from "./rules/number.js";
50
+ import M from "./rules/number.js";
10
51
  import O from "./rules/object.js";
11
- import A from "./rules/string.js";
12
- import P from "./rules/type.js";
13
- import { mergeTemplate as y } from "./utils.js";
14
- const f = (l, e) => new b(l, { field: "value", ...e });
15
- f.globalConfig = {};
16
- f.setGlobalConfig = (l) => {
17
- f.globalConfig = V(
52
+ import q from "./rules/string.js";
53
+ import A from "./rules/type.js";
54
+ const l = (p, t) => new y(p, { field: "value", ...t });
55
+ l.globalConfig = {};
56
+ l.setGlobalConfig = (p) => {
57
+ l.globalConfig = g(
18
58
  {},
19
- l,
20
- f.globalConfig
59
+ p,
60
+ l.globalConfig
21
61
  );
22
62
  };
23
- class b {
24
- constructor(e, a) {
25
- const n = f.globalConfig, s = {
26
- ...n,
63
+ class y {
64
+ constructor(t, a) {
65
+ const m = l.globalConfig, o = {
66
+ ...m,
27
67
  ...a,
28
- validateMessages: y(
29
- n.validateMessages,
30
- a.validateMessages
68
+ validateMessages: g(
69
+ {},
70
+ a.validateMessages,
71
+ m.validateMessages
31
72
  )
32
73
  };
33
- this.string = new A(e, s), this.number = new q(e, s), this.array = new C(e, s), this.object = new O(e, s), this.boolean = new M(e, s), this.type = new P(e, s), this.custom = new S(e, s);
74
+ this.string = new q(t, o), this.number = new M(t, o), this.array = new C(t, o), this.object = new O(t, o), this.boolean = new E(t, o), this.type = new A(t, o), this.custom = new S(t, o);
34
75
  }
35
76
  }
36
- class U {
37
- constructor(e, a = {}) {
38
- this.schema = e, this.options = a;
77
+ class Ti {
78
+ constructor(t, a = {}) {
79
+ this.schema = t, this.options = a;
39
80
  }
40
81
  // 更新校验信息
41
- messages(e) {
82
+ messages(t) {
42
83
  this.options = {
43
84
  ...this.options,
44
- validateMessages: y(
45
- this.options.validateMessages,
46
- e
85
+ validateMessages: g(
86
+ {},
87
+ t,
88
+ this.options.validateMessages
47
89
  )
48
90
  };
49
91
  }
50
- validate(e, a) {
51
- if (!v(e)) return;
52
- const n = [];
53
- let s = null;
54
- function m(t, h) {
55
- s || (s = {}), s && (!s[t] || h.requiredError) && (s[t] = h);
92
+ validate(t, a) {
93
+ if (!V(t)) return;
94
+ const m = [];
95
+ let o = null;
96
+ function f(r, n) {
97
+ o || (o = {}), o && (!o[r] || n.requiredError) && (o[r] = n);
56
98
  }
57
- this.schema && Object.entries(this.schema).forEach(([t, h], T, x) => {
58
- if (u(this.schema[t]))
59
- for (let c = 0; c < this.schema[t].length; c++) {
60
- const o = this.schema[t][c], g = o.type, w = o.message;
61
- if (!g) {
62
- if (!o.validator) throw `You must specify a type to field ${t}!`;
99
+ this.schema && Object.entries(this.schema).forEach(([r, n], B, N) => {
100
+ if (u(n))
101
+ for (const e of n) {
102
+ const d = e.type, b = e.message;
103
+ if (!d) {
104
+ if (!e.validator) throw `You must specify a type to field ${r}!`;
63
105
  }
64
- const p = {
106
+ const c = {
65
107
  ...this.options,
66
- message: w,
67
- field: t
108
+ message: b,
109
+ field: r
68
110
  };
69
- "ignoreEmptyString" in o && (p.ignoreEmptyString = o.ignoreEmptyString), "strict" in o && (p.strict = o.strict);
70
- const d = new b(e[t], p);
71
- let i = d.type[g] || null;
72
- if (!i) if (o.validator) {
73
- i = d.custom.validate_(o.validator), u(i) && i[0]?.then ? n.push({
111
+ "ignoreEmptyString" in e && (c.ignoreEmptyString = e.ignoreEmptyString), "strict" in e && (c.strict = e.strict);
112
+ const h = new y(t[r], c);
113
+ let i = h.type[d] || null;
114
+ if (!i) if (e.validator) {
115
+ i = h.custom.validate2(e.validator), u(i) && i[0]?.then ? m.push({
74
116
  function: i[0],
75
117
  _this: i[1],
76
- key: t
77
- }) : i && m(t, i);
118
+ key: r
119
+ }) : i && f(r, i);
78
120
  continue;
79
121
  } else
80
- i = d[g];
81
- if (Object.entries(o).forEach(([r, B], D, F) => {
82
- o.required && (i = i.isRequired), r !== "message" && i?.[r] && o[r] && v(i[r]) && (i = i[r]), i?.[r] && o[r] !== void 0 && E(i[r]) && (i = i[r](o[r]));
83
- }), i.collect((r) => {
84
- r && m(t, r);
85
- }), s)
122
+ i = h[d];
123
+ if (Object.entries(e).forEach(([s, P], T, x) => {
124
+ e.required && (i = i.isRequired), s !== "message" && i?.[s] && e[s] && V(i[s]) && (i = i[s]), i?.[s] && !w(e[s]) && v(i[s]) && (i = i[s](e[s]));
125
+ }), i.collect((s) => {
126
+ s && f(r, s);
127
+ }), o)
86
128
  break;
87
129
  }
88
- }), n.length > 0 ? Promise.all(n.map((t) => t.function)).then(() => {
89
- n.forEach((t) => {
90
- "error" in t._this && t._this.error && m(t.key, t._this.error);
91
- }), a?.(s);
92
- }) : a?.(s);
130
+ }), m.length > 0 ? Promise.all(m.map((r) => r.function)).then(() => {
131
+ m.forEach((r) => {
132
+ "error" in r._this && r._this.error && f(r.key, r._this.error);
133
+ }), a?.(o);
134
+ }) : a?.(o);
93
135
  }
94
136
  }
95
137
  export {
96
- C as ArrayValidator,
97
- M as BooleanValidator,
98
- S as CustomValidator,
99
- q as NumberValidator,
100
- O as ObjectValidator,
101
- U as Schema,
102
- A as StringValidator,
103
- P as TypeValidator,
104
- f as default,
105
- y as mergeTemplate
138
+ l as PqbValidator,
139
+ y as Validator,
140
+ C as ValidatorArray,
141
+ E as ValidatorBoolean,
142
+ S as ValidatorCustom,
143
+ M as ValidatorNumber,
144
+ O as ValidatorObject,
145
+ Ti as ValidatorSchema,
146
+ q as ValidatorString,
147
+ A as ValidatorType,
148
+ y as default
106
149
  };
@@ -1,15 +1,25 @@
1
- /* 2025-11-19 10:03:21 */
1
+ /* 2025-12-17 18:26:57 */
2
2
  const e = "#{field} is not a #{type} type", t = {
3
3
  required: "#{field} is required",
4
4
  type: {
5
5
  ip: e,
6
+ port: e,
7
+ mac: e,
6
8
  email: e,
7
9
  url: e,
8
10
  string: e,
9
11
  number: e,
10
12
  array: e,
11
13
  object: e,
12
- boolean: e
14
+ boolean: e,
15
+ strongPassword: e,
16
+ identity: e,
17
+ phone: e,
18
+ semver: e,
19
+ ascii: e,
20
+ halfWidth: e,
21
+ fullWidth: e,
22
+ chinese: e
13
23
  },
14
24
  number: {
15
25
  min: "`#{value}` is not greater than `#{min}`",
@@ -0,0 +1,11 @@
1
+ /* 2025-12-17 18:26:57 */
2
+ import t from "./en-US.js";
3
+ import o from "./zh-CN.js";
4
+ const a = {
5
+ en_US: t,
6
+ zh_CN: o,
7
+ default: o
8
+ };
9
+ export {
10
+ a as default
11
+ };
@@ -1,4 +1,4 @@
1
- /* 2025-11-19 10:03:21 */
1
+ /* 2025-12-17 18:26:57 */
2
2
  const e = {
3
3
  required: "#{field} 是必填项",
4
4
  type: {
@@ -9,7 +9,17 @@ const e = {
9
9
  object: "#{field} 不是合法的对象类型",
10
10
  url: "#{field} 不是合法的 url 地址",
11
11
  email: "#{field} 不是合法的邮箱地址",
12
- ip: "#{field} 不是合法的 IP 地址"
12
+ ip: "#{field} 不是合法的 IP 地址",
13
+ port: "#{field} 不是合法的端口",
14
+ mac: "#{field} 不是合法的 mac 地址",
15
+ identity: "#{field} 不是合法的身份证号码",
16
+ phone: "#{field} 不是合法的手机号码",
17
+ strongPassword: "#{field} 不是强密码",
18
+ semver: "#{field} 不是合法的语义化版本",
19
+ ascii: "#{field} 不是合法的 ASCII 字符",
20
+ halfWidth: "#{field} 不是合法的半角字符",
21
+ fullWidth: "#{field} 不是合法的全角字符",
22
+ chinese: "#{field} 不是中文字符"
13
23
  },
14
24
  number: {
15
25
  min: "`#{value}` 小于最小值 `#{min}`",
@@ -1,4 +1,4 @@
1
- /* 2025-11-19 10:03:21 */
1
+ /* 2025-12-17 18:26:57 */
2
2
  import i from "lodash/isArray.js";
3
3
  import a from "lodash/isEqual.js";
4
4
  import { isEmptyArray as s } from "../../../is/index.js";
@@ -45,7 +45,7 @@ class d extends h {
45
45
  }
46
46
  includes(t) {
47
47
  return this.object ? this.validate(
48
- t.every((e) => this.object.indexOf(e) !== -1),
48
+ t.every((e) => this.object.includes(e)),
49
49
  this.getValidateMsg("array.includes", {
50
50
  value: this.object,
51
51
  includes: t
@@ -1,48 +1,52 @@
1
- /* 2025-11-19 10:03:21 */
2
- import n from "lodash/isArray.js";
3
- import f from "lodash/isFunction.js";
4
- import h from "lodash/isObject.js";
5
- import l from "lodash/isString.js";
6
- import { isEmptyValue as g, isEmptyArray as u } from "../../../is/index.js";
7
- import c from "../locale/zh-CN.js";
8
- import { getTemplate as d, mergeTemplate as p } from "../utils.js";
9
- class S {
1
+ /* 2025-12-17 18:26:57 */
2
+ import n from "lodash/defaultsDeep.js";
3
+ import f from "lodash/get.js";
4
+ import u from "lodash/isArray.js";
5
+ import d from "lodash/isFunction.js";
6
+ import s from "lodash/isObject.js";
7
+ import c from "lodash/isString.js";
8
+ import { isEmptyValue as g, isEmptyArray as y } from "../../../is/index.js";
9
+ import p from "../locale/index.js";
10
+ class q {
10
11
  constructor(t, e) {
11
- this.getValidateMsg = (a, m = {}) => {
12
- const r = Object.assign({}, m, {
12
+ this.locale = "zh-CN", this.getValidateMsg = (l, m = {}) => {
13
+ const a = Object.assign({}, m, {
13
14
  value: this.object,
14
15
  field: this.field,
16
+ label: this.label,
15
17
  type: this.type
16
- }), s = d(this.validateMessages, a);
17
- return f(s) ? s(r) : l(s) ? s.replace(/#\{.+?\}/g, (o) => {
18
- const i = o.slice(2, -1);
19
- if (i in r) {
20
- if (h(r[i]) || n(r[i]))
18
+ }), r = f(this.validateMessages, l);
19
+ return d(r) ? r(a) : c(r) ? r.replace(/#\{.+?\}/g, (h) => {
20
+ const o = h.slice(2, -1);
21
+ if (o in a) {
22
+ const i = a[o];
23
+ if (s(i) || u(i))
21
24
  try {
22
- return JSON.stringify(r[i]);
25
+ return JSON.stringify(i);
23
26
  } catch {
24
- return r[i];
27
+ return String(i);
25
28
  }
26
- return String(r[i]);
29
+ return String(i);
27
30
  }
28
- return o;
29
- }) : s;
30
- }, h(e) && l(t) && e.trim ? this.object = t.trim() : h(e) && e.ignoreEmptyString && t === "" ? this.object = void 0 : this.object = t, this.message = e.message, this.type = e.type, this.error = null, this.field = e.field || e.type, this.validateMessages = p(
31
- c,
32
- e.validateMessages
33
- );
31
+ return h;
32
+ }) : r;
33
+ }, s(e) && c(t) && e.trim ? this.object = t.trim() : s(e) && e.ignoreEmptyString && t === "" ? this.object = void 0 : this.object = t, this.message = e.message, this.type = e.type, this.error = null, this.label = e.label, this.field = e.field || e.type, this.validateMessages = n(
34
+ {},
35
+ e.validateMessages,
36
+ p.default
37
+ ), this.locale = e.locale;
34
38
  }
35
39
  get not() {
36
- return this._not = !this._not, this;
40
+ return this.not_ = !this.not_, this;
37
41
  }
38
42
  get isRequired() {
39
- if (g(this.object) || u(this.object)) {
43
+ if (g(this.object) || y(this.object)) {
40
44
  const t = this.getValidateMsg("required");
41
45
  this.error = {
42
46
  value: this.object,
43
47
  type: this.type,
44
48
  requiredError: !0,
45
- message: this.message || (h(t) ? t : `${this._not ? "[NOT MODE]:" : ""}${t}`)
49
+ message: this.message || (s(t) ? t : `${this.not_ ? "[NOT MODE]:" : ""}${t}`)
46
50
  };
47
51
  }
48
52
  return this;
@@ -54,16 +58,16 @@ class S {
54
58
  this.error || t && (this.error = {
55
59
  value: this.object,
56
60
  type: this.type,
57
- message: this.message || (h(t) ? t : `${this._not ? "[NOT MODE]:" : ""}${t}`)
61
+ message: this.message || (s(t) ? t : `${this.not_ ? "[NOT MODE]:" : ""}${t}`)
58
62
  });
59
63
  }
60
64
  validate(t, e) {
61
- return (this._not ? t : !t) && this.addError(e), this;
65
+ return (this.not_ ? t : !t) && this.addError(e), this;
62
66
  }
63
67
  collect(t) {
64
68
  t?.(this.error);
65
69
  }
66
70
  }
67
71
  export {
68
- S as default
72
+ q as default
69
73
  };
@@ -1,4 +1,4 @@
1
- /* 2025-11-19 10:03:21 */
1
+ /* 2025-12-17 18:26:57 */
2
2
  import a from "lodash/isBoolean.js";
3
3
  import s from "./base.js";
4
4
  class r extends s {
@@ -1,4 +1,4 @@
1
- /* 2025-11-19 10:03:21 */
1
+ /* 2025-12-17 18:26:57 */
2
2
  import o from "./base.js";
3
3
  class n extends o {
4
4
  constructor(t, r) {
@@ -7,7 +7,7 @@ class n extends o {
7
7
  type: "custom"
8
8
  });
9
9
  }
10
- validate_(t, r) {
10
+ validate2(t, r) {
11
11
  if (t) {
12
12
  const e = t(this.object, this.addError.bind(this));
13
13
  return e && e.then ? (r && e.then(
@@ -1,4 +1,4 @@
1
- /* 2025-11-19 10:03:21 */
1
+ /* 2025-12-17 18:26:57 */
2
2
  import s from "lodash/isNumber.js";
3
3
  import { isEmptyValue as i } from "../../../is/index.js";
4
4
  import a from "./base.js";
@@ -1,4 +1,4 @@
1
- /* 2025-11-19 10:03:21 */
1
+ /* 2025-12-17 18:26:57 */
2
2
  import s from "lodash/isEqual.js";
3
3
  import i from "lodash/isObject.js";
4
4
  import { isEmptyObject as a } from "../../../is/index.js";
@@ -1,7 +1,8 @@
1
- /* 2025-11-19 10:03:21 */
1
+ /* 2025-12-17 18:26:57 */
2
2
  import i from "lodash/isString.js";
3
- import s from "./base.js";
4
- class r extends s {
3
+ import s from "lodash/isUndefined.js";
4
+ import a from "./base.js";
5
+ class o extends a {
5
6
  constructor(t, e) {
6
7
  super(t, {
7
8
  ...e,
@@ -32,7 +33,7 @@ class r extends s {
32
33
  match(t) {
33
34
  const e = t instanceof RegExp;
34
35
  return e && (t.lastIndex = 0), this.validate(
35
- this.object === void 0 || e && t.test(this.object),
36
+ s(this.object) || e && t.test(this.object),
36
37
  this.getValidateMsg("string.match", { pattern: t })
37
38
  );
38
39
  }
@@ -50,5 +51,5 @@ class r extends s {
50
51
  }
51
52
  }
52
53
  export {
53
- r as default
54
+ o as default
54
55
  };
@@ -1,35 +1,105 @@
1
- /* 2025-11-19 10:03:21 */
2
- import a from "./base.js";
3
- const s = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/, i = new RegExp(
4
- "^(?!mailto:)(?:(?:http|https|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$",
5
- "i"
6
- ), d = /^(2(5[0-5]{1}|[0-4]\d{1})|[0-1]?\d{1,2})(\.(2(5[0-5]{1}|[0-4]\d{1})|[0-1]?\d{1,2})){3}$/;
7
- class l extends a {
8
- constructor(t, e) {
9
- super(t, {
10
- ...e,
1
+ /* 2025-12-17 18:26:57 */
2
+ import t from "lodash/isUndefined";
3
+ import r from "../../../is/lib/isAscii.js";
4
+ import { isAllChinese as o } from "../../../is/lib/isChinese.js";
5
+ import a from "../../../is/lib/isEmail.js";
6
+ import e from "../../../is/lib/isFullWidth.js";
7
+ import i from "../../../is/lib/isHalfWidth.js";
8
+ import l from "../../../is/lib/isIdentityCard.js";
9
+ import p from "../../../is/lib/isIP.js";
10
+ import d from "../../../is/lib/isMACAddress.js";
11
+ import c from "../../../is/lib/isMobilePhone.js";
12
+ import g from "../../../is/lib/isPort.js";
13
+ import m from "../../../is/lib/isSemVer.js";
14
+ import n from "../../../is/lib/isStrongPassword.js";
15
+ import y from "../../../is/lib/isURL.js";
16
+ import b from "./base.js";
17
+ class E extends b {
18
+ constructor(s, h) {
19
+ super(s, {
20
+ ...h,
11
21
  type: "type"
12
22
  });
13
23
  }
14
24
  get email() {
15
25
  return this.type = "email", this.validate(
16
- this.object === void 0 || s.test(this.object),
26
+ t(this.object) || a(this.object),
17
27
  this.getValidateMsg("type.email")
18
28
  );
19
29
  }
20
30
  get url() {
21
31
  return this.type = "url", this.validate(
22
- this.object === void 0 || i.test(this.object),
32
+ t(this.object) || y(this.object),
23
33
  this.getValidateMsg("type.url")
24
34
  );
25
35
  }
26
36
  get ip() {
27
37
  return this.type = "ip", this.validate(
28
- this.object === void 0 || d.test(this.object),
38
+ t(this.object) || p(this.object),
29
39
  this.getValidateMsg("type.ip")
30
40
  );
31
41
  }
42
+ get port() {
43
+ return this.type = "port", this.validate(
44
+ t(this.object) || g(this.object),
45
+ this.getValidateMsg("type.port")
46
+ );
47
+ }
48
+ get strongPassword() {
49
+ return this.type = "strongPassword", this.validate(
50
+ t(this.object) || n(this.object),
51
+ this.getValidateMsg("type.strongPassword")
52
+ );
53
+ }
54
+ get mac() {
55
+ return this.type = "mac", this.validate(
56
+ t(this.object) || d(this.object),
57
+ this.getValidateMsg("type.mac")
58
+ );
59
+ }
60
+ get identity() {
61
+ return this.type = "identity", this.validate(
62
+ t(this.object) || l(this.object, this.locale),
63
+ this.getValidateMsg("type.identity")
64
+ );
65
+ }
66
+ get phone() {
67
+ return this.type = "phone", this.validate(
68
+ t(this.object) || c(this.object, this.locale),
69
+ this.getValidateMsg("type.phone")
70
+ );
71
+ }
72
+ get semver() {
73
+ return this.type = "semver", this.validate(
74
+ t(this.object) || m(this.object),
75
+ this.getValidateMsg("type.semver")
76
+ );
77
+ }
78
+ get ascii() {
79
+ return this.type = "ascii", this.validate(
80
+ t(this.object) || r(this.object),
81
+ this.getValidateMsg("type.ascii")
82
+ );
83
+ }
84
+ get halfWidth() {
85
+ return this.type = "halfWidth", this.validate(
86
+ t(this.object) || i(this.object) && !e(this.object),
87
+ this.getValidateMsg("type.halfWidth")
88
+ );
89
+ }
90
+ get fullWidth() {
91
+ return this.type = "fullWidth", this.validate(
92
+ t(this.object) || e(this.object) && !i(this.object),
93
+ this.getValidateMsg("type.fullWidth")
94
+ );
95
+ }
96
+ get chinese() {
97
+ return this.type = "chinese", this.validate(
98
+ t(this.object) || o(this.object),
99
+ this.getValidateMsg("type.chinese")
100
+ );
101
+ }
32
102
  }
33
103
  export {
34
- l as default
104
+ E as default
35
105
  };
package/validate.js CHANGED
@@ -1,28 +1,26 @@
1
- /* 2025-11-19 10:03:21 */
2
- import { Schema as t, default as o } from "./validate/src/index.js";
3
- import { default as l } from "./validate/src/rules/array.js";
4
- import { default as d } from "./validate/src/rules/boolean.js";
5
- import { default as u } from "./validate/src/rules/custom.js";
6
- import { default as p, default as i, default as x } from "./validate/src/locale/zh-CN.js";
7
- import { default as c } from "./validate/src/locale/en-US.js";
1
+ /* 2025-12-17 18:26:57 */
2
+ import { PqbValidator as r, Validator as t, ValidatorSchema as e, Validator as l } from "./validate/src/index.js";
3
+ import { default as f } from "./validate/src/rules/array.js";
4
+ import { default as m } from "./validate/src/rules/base.js";
5
+ import { default as u } from "./validate/src/rules/boolean.js";
6
+ import { default as p } from "./validate/src/rules/custom.js";
7
+ import { default as b } from "./validate/src/locale/index.js";
8
8
  import { default as n } from "./validate/src/rules/number.js";
9
- import { default as S } from "./validate/src/rules/object.js";
10
- import { default as h } from "./validate/src/rules/string.js";
11
- import { default as C } from "./validate/src/rules/type.js";
12
- import { mergeTemplate as T } from "./validate/src/utils.js";
9
+ import { default as B } from "./validate/src/rules/object.js";
10
+ import { default as g } from "./validate/src/rules/string.js";
11
+ import { default as j } from "./validate/src/rules/type.js";
13
12
  export {
14
- l as ArrayValidator,
15
- d as BooleanValidator,
16
- u as CustomValidator,
17
- p as DefaultValidateMessage,
18
- n as NumberValidator,
19
- S as ObjectValidator,
20
- t as Schema,
21
- h as StringValidator,
22
- C as TypeValidator,
23
- o as default,
24
- i as defaultValidateLocale,
25
- c as enUSValidateLocale,
26
- T as mergeTemplate,
27
- x as zhCNValidateLocale
13
+ r as PqbValidator,
14
+ t as Validator,
15
+ f as ValidatorArray,
16
+ m as ValidatorBase,
17
+ u as ValidatorBoolean,
18
+ p as ValidatorCustom,
19
+ n as ValidatorNumber,
20
+ B as ValidatorObject,
21
+ e as ValidatorSchema,
22
+ g as ValidatorString,
23
+ j as ValidatorType,
24
+ l as default,
25
+ b as validatorLocale
28
26
  };
package/version/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /* 2025-11-19 10:03:21 */
1
+ /* 2025-12-17 18:26:57 */
2
2
  const t = "0.0.0";
3
3
  export {
4
4
  t as VERSION,