@unicom-cloud/utils 0.1.32 → 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.
- package/case-name/index.js +1 -1
- package/caseName.js +1 -1
- package/class-name/index.js +1 -1
- package/className.js +1 -1
- package/clipboard-copy/index.js +1 -1
- package/clipboardCopy.js +1 -1
- package/constant/address.js +1 -1
- package/constant/chineseCharacters.js +1 -1
- package/constant/constellations.js +1 -1
- package/constant/domain.js +1 -1
- package/constant/emoji.js +1 -1
- package/constant/identity.js +1 -1
- package/constant/index.js +1 -1
- package/constant/isMobile.js +1 -1
- package/constant/keyboardCode.js +1 -1
- package/constant/licensePlate.js +1 -1
- package/constant/name.js +1 -1
- package/constant/platform.js +1 -1
- package/constant/protocol.js +1 -1
- package/constant/string.js +1 -1
- package/constant/ui.js +1 -1
- package/constant.js +1 -1
- package/content-disposition/index.js +1 -1
- package/contentDisposition.js +1 -1
- package/cookie/index.js +1 -1
- package/cookie/src/api.js +1 -1
- package/cookie/src/assign.js +1 -1
- package/cookie/src/converter.js +1 -1
- package/cookie.js +1 -1
- package/date/convertTime.js +1 -1
- package/date/convertToDuration.js +1 -1
- package/date/index.js +5 -5
- package/date.js +5 -5
- package/decimal/decimal.js +1 -1
- package/decimal/index.js +1 -1
- package/decimal.js +1 -1
- package/dom-helpers/activeElement.js +1 -1
- package/dom-helpers/addClass.js +1 -1
- package/dom-helpers/addEventListener.js +1 -1
- package/dom-helpers/animate.js +1 -1
- package/dom-helpers/animationFrame.js +1 -1
- package/dom-helpers/attribute.js +1 -1
- package/dom-helpers/camelize.js +1 -1
- package/dom-helpers/camelizeStyle.js +1 -1
- package/dom-helpers/canUseDOM.js +1 -1
- package/dom-helpers/childElements.js +1 -1
- package/dom-helpers/childNodes.js +1 -1
- package/dom-helpers/clear.js +1 -1
- package/dom-helpers/closest.js +1 -1
- package/dom-helpers/collectElements.js +1 -1
- package/dom-helpers/collectSiblings.js +1 -1
- package/dom-helpers/contains.js +1 -1
- package/dom-helpers/css.js +1 -1
- package/dom-helpers/filterEventHandler.js +1 -1
- package/dom-helpers/getComputedStyle.js +1 -1
- package/dom-helpers/getElementCoordinates.js +46 -0
- package/dom-helpers/getScrollAccessor.js +1 -1
- package/dom-helpers/hasClass.js +1 -1
- package/dom-helpers/height.js +1 -1
- package/dom-helpers/hyphenate.js +1 -1
- package/dom-helpers/hyphenateStyle.js +1 -1
- package/dom-helpers/index.js +87 -84
- package/dom-helpers/insertAfter.js +1 -1
- package/dom-helpers/isDocument.js +1 -1
- package/dom-helpers/isInput.js +1 -1
- package/dom-helpers/isTransform.js +1 -1
- package/dom-helpers/isVisible.js +1 -1
- package/dom-helpers/isWindow.js +1 -1
- package/dom-helpers/listen.js +1 -1
- package/dom-helpers/matches.js +1 -1
- package/dom-helpers/nextUntil.js +1 -1
- package/dom-helpers/offset.js +1 -1
- package/dom-helpers/offsetParent.js +1 -1
- package/dom-helpers/ownerDocument.js +1 -1
- package/dom-helpers/ownerWindow.js +1 -1
- package/dom-helpers/parents.js +1 -1
- package/dom-helpers/position.js +1 -1
- package/dom-helpers/prepend.js +1 -1
- package/dom-helpers/querySelectorAll.js +1 -1
- package/dom-helpers/reflow.js +1 -1
- package/dom-helpers/remove.js +1 -1
- package/dom-helpers/removeClass.js +1 -1
- package/dom-helpers/removeEventListener.js +1 -1
- package/dom-helpers/scrollLeft.js +1 -1
- package/dom-helpers/scrollParent.js +1 -1
- package/dom-helpers/scrollTo.js +1 -1
- package/dom-helpers/scrollTop.js +1 -1
- package/dom-helpers/scrollbarSize.js +1 -1
- package/dom-helpers/siblings.js +1 -1
- package/dom-helpers/text.js +1 -1
- package/dom-helpers/toggleClass.js +1 -1
- package/dom-helpers/transitionEnd.js +2 -2
- package/dom-helpers/triggerEvent.js +1 -1
- package/dom-helpers/types.js +1 -1
- package/dom-helpers/width.js +1 -1
- package/domHelpers.js +65 -63
- package/emitter/index.js +1 -1
- package/emitter/src/index.js +1 -1
- package/emitter.js +1 -1
- package/escape/index.js +11 -0
- package/escape.js +6 -0
- package/file/fileToURL.js +1 -1
- package/file/index.js +1 -1
- package/file/saveAs.js +1 -1
- package/file.js +1 -1
- package/idb/index.js +1 -1
- package/idb.js +1 -1
- package/index.js +1 -1
- package/invariant/index.js +1 -1
- package/invariant.js +1 -1
- package/is/index.js +196 -141
- package/is/lib/isAscii.js +9 -0
- package/is/lib/isBase64.js +13 -0
- package/is/lib/isChinese.js +19 -0
- package/is/lib/isDataURI.js +25 -0
- package/is/lib/isEmail.js +72 -0
- package/is/lib/isFQDN.js +21 -0
- package/is/lib/isFullWidth.js +10 -0
- package/is/lib/isHSL.js +11 -0
- package/is/lib/isHalfWidth.js +10 -0
- package/is/lib/isHash.js +23 -0
- package/is/lib/isHexColor.js +12 -0
- package/is/lib/isIMEI.js +19 -0
- package/is/lib/isIP.js +21 -0
- package/is/lib/isIPRange.js +25 -0
- package/is/lib/isIdentityCard.js +190 -0
- package/is/lib/isJWT.js +14 -0
- package/is/lib/isMACAddress.js +9 -0
- package/is/lib/isMD5.js +9 -0
- package/is/lib/isMimeType.js +9 -0
- package/is/lib/isMobilePhone.js +192 -0
- package/is/lib/isPort.js +7 -0
- package/is/lib/isRgbColor.js +18 -0
- package/is/lib/isSemVer.js +20 -0
- package/is/lib/isSlug.js +9 -0
- package/is/lib/isStrongPassword.js +48 -0
- package/is/lib/isURL.js +78 -0
- package/is/lib/isUUID.js +24 -0
- package/is/lib/isVariableWidth.js +10 -0
- package/is/lib/util/assertString.js +12 -0
- package/is.js +122 -66
- package/lunar/index.js +1 -1
- package/lunar/lib/Holiday.js +1 -1
- package/lunar/lib/HolidayUtil.js +1 -1
- package/lunar/lib/I18n.js +1 -1
- package/lunar/lib/JieQi.js +1 -1
- package/lunar/lib/Lunar.js +1 -1
- package/lunar/lib/LunarMonth.js +1 -1
- package/lunar/lib/LunarTime.js +1 -1
- package/lunar/lib/LunarUtil.js +1 -1
- package/lunar/lib/LunarYear.js +1 -1
- package/lunar/lib/ShouXingUtil.js +1 -1
- package/lunar/lib/Solar.js +1 -1
- package/lunar/lib/SolarHalfYear.js +1 -1
- package/lunar/lib/SolarMonth.js +1 -1
- package/lunar/lib/SolarSeason.js +1 -1
- package/lunar/lib/SolarUtil.js +1 -1
- package/lunar/lib/SolarWeek.js +1 -1
- package/lunar/lib/SolarYear.js +1 -1
- package/lunar/lib/index.js +1 -1
- package/lunar.js +1 -1
- package/math/index.js +1 -1
- package/math.js +1 -1
- package/md5/index.js +1 -1
- package/md5.js +1 -1
- package/mock/MockWebSocket.js +1 -1
- package/mock/MockXMLHttpRequest.js +1 -1
- package/mock/index.js +1 -1
- package/mock.js +1 -1
- package/normalize-wheel/ExecutionEnvironment.js +1 -1
- package/normalize-wheel/UserAgent_DEPRECATED.js +1 -1
- package/normalize-wheel/index.js +1 -1
- package/normalize-wheel/isEventSupported.js +1 -1
- package/normalizeWheel.js +1 -1
- package/number-to-chinese/index.js +1 -1
- package/numberToChinese.js +1 -1
- package/nzh/cn.js +1 -1
- package/nzh/hk.js +1 -1
- package/nzh/index.js +1 -1
- package/nzh/nzh.js +1 -1
- package/nzh/src/autoGet.js +1 -1
- package/nzh/src/index.js +1 -1
- package/nzh/src/langs/cn_b.js +1 -1
- package/nzh/src/langs/cn_s.js +1 -1
- package/nzh/src/langs/hk_b.js +1 -1
- package/nzh/src/langs/hk_s.js +1 -1
- package/nzh/src/utils.js +1 -1
- package/nzh.js +1 -1
- package/object-keys-sort/index.js +1 -1
- package/object-prototype-to-string-call/index.js +2 -2
- package/objectKeysSort.js +1 -1
- package/objectPrototypeToStringCall.js +1 -1
- package/package.json +1 -1
- package/pinyin/index.js +1 -1
- package/pinyin/simplified.js +1 -1
- package/pinyin/src/core.js +1 -1
- package/pinyin/src/simplified.js +6 -6
- package/pinyin/src/simplified_dict.js +5 -4
- package/pinyin/src/traditional.js +4 -4
- package/pinyin/src/traditional_dict.js +4 -3
- package/pinyin/traditional.js +1 -1
- package/pinyin.js +1 -1
- package/query-string/base.js +1 -1
- package/query-string/index.js +1 -1
- package/query-string/splitOnFirst.js +1 -1
- package/queryString.js +1 -1
- package/random/address.js +1 -1
- package/random/constellation.js +1 -1
- package/random/image.js +1 -1
- package/random/index.js +1 -1
- package/random/licensePlate.js +1 -1
- package/random/name.js +1 -1
- package/random/number.js +1 -1
- package/random/text.js +1 -1
- package/random/time.js +1 -1
- package/random/web.js +1 -1
- package/random.js +1 -1
- package/screenfull/index.js +1 -1
- package/screenfull.js +1 -1
- package/sleep/index.js +1 -1
- package/sleep.js +1 -1
- package/snapdom/index.js +1 -1
- package/snapdom/src/api/preCache.js +1 -1
- package/snapdom/src/api/snapdom.js +2 -2
- package/snapdom/src/core/cache.js +1 -1
- package/snapdom/src/core/capture.js +1 -1
- package/snapdom/src/core/clone.js +1 -1
- package/snapdom/src/core/context.js +1 -1
- package/snapdom/src/core/plugins.js +1 -1
- package/snapdom/src/core/prepare.js +1 -1
- package/snapdom/src/exporters/download.js +14 -9
- package/snapdom/src/exporters/toBlob.js +1 -1
- package/snapdom/src/exporters/toCanvas.js +1 -1
- package/snapdom/src/exporters/toImg.js +1 -1
- package/snapdom/src/modules/CSSVar.js +1 -1
- package/snapdom/src/modules/background.js +1 -1
- package/snapdom/src/modules/changeCSS.js +1 -1
- package/snapdom/src/modules/counter.js +1 -1
- package/snapdom/src/modules/fonts.js +1 -1
- package/snapdom/src/modules/iconFonts.js +1 -1
- package/snapdom/src/modules/images.js +1 -1
- package/snapdom/src/modules/lineClamp.js +1 -1
- package/snapdom/src/modules/pseudo.js +1 -1
- package/snapdom/src/modules/rasterize.js +1 -1
- package/snapdom/src/modules/snapFetch.js +1 -1
- package/snapdom/src/modules/styles.js +2 -2
- package/snapdom/src/modules/svgDefs.js +1 -1
- package/snapdom/src/utils/browser.js +1 -1
- package/snapdom/src/utils/capture.helpers.js +1 -1
- package/snapdom/src/utils/clone.helpers.js +1 -1
- package/snapdom/src/utils/css.js +1 -1
- package/snapdom/src/utils/helpers.js +1 -1
- package/snapdom/src/utils/image.js +1 -1
- package/snapdom/src/utils/prepare.helpers.js +1 -1
- package/snapdom/src/utils/transforms.helpers.js +1 -1
- package/snapdom.js +1 -1
- package/string/index.js +1 -1
- package/string.js +1 -1
- package/tinycolor/index.js +1 -1
- package/tinycolor/src/conversion.js +1 -1
- package/tinycolor/src/css-color-names.js +1 -1
- package/tinycolor/src/format-input.js +1 -1
- package/tinycolor/src/from-ratio.js +12 -11
- package/tinycolor/src/index.js +1 -1
- package/tinycolor/src/random.js +30 -29
- package/tinycolor/src/readability.js +1 -1
- package/tinycolor/src/to-ms-filter.js +1 -1
- package/tinycolor/src/utils.js +1 -1
- package/tinycolor.js +1 -1
- package/tree/index.js +54 -75
- package/tree/search/index.js +1 -1
- package/tree.js +9 -11
- package/tween/index.js +1 -1
- package/tween/src/easing.js +1 -1
- package/tween/src/tween.js +15 -14
- package/tween.js +1 -1
- package/types/date/index.d.ts +3 -3
- package/types/dom-helpers/getElementCoordinates.d.ts +40 -0
- package/types/dom-helpers/index.d.ts +3 -1
- package/types/escape/index.d.ts +2 -0
- package/types/is/index.d.ts +28 -1
- package/types/is/lib/isAscii.d.ts +1 -0
- package/types/is/lib/isBase64.d.ts +1 -0
- package/types/is/lib/isChinese.d.ts +4 -0
- package/types/is/lib/isDataURI.d.ts +1 -0
- package/types/is/lib/isEmail.d.ts +1 -0
- package/types/is/lib/isFQDN.d.ts +1 -0
- package/types/is/lib/isFullWidth.d.ts +2 -0
- package/types/is/lib/isHSL.d.ts +1 -0
- package/types/is/lib/isHalfWidth.d.ts +2 -0
- package/types/is/lib/isHash.d.ts +1 -0
- package/types/is/lib/isHexColor.d.ts +1 -0
- package/types/is/lib/isIMEI.d.ts +1 -0
- package/types/is/lib/isIP.d.ts +1 -0
- package/types/is/lib/isIPRange.d.ts +1 -0
- package/types/is/lib/isIdentityCard.d.ts +1 -0
- package/types/is/lib/isJWT.d.ts +1 -0
- package/types/is/lib/isMACAddress.d.ts +1 -0
- package/types/is/lib/isMD5.d.ts +1 -0
- package/types/is/lib/isMimeType.d.ts +1 -0
- package/types/is/lib/isMobilePhone.d.ts +2 -0
- package/types/is/lib/isOctal.d.ts +1 -0
- package/types/is/lib/isPort.d.ts +1 -0
- package/types/is/lib/isRgbColor.d.ts +1 -0
- package/types/is/lib/isSemVer.d.ts +1 -0
- package/types/is/lib/isSlug.d.ts +1 -0
- package/types/is/lib/isStrongPassword.d.ts +1 -0
- package/types/is/lib/isURL.d.ts +1 -0
- package/types/is/lib/isUUID.d.ts +1 -0
- package/types/is/lib/isVariableWidth.d.ts +1 -0
- package/types/is/lib/util/assertString.d.ts +1 -0
- package/types/pinyin/es/main.d.ts +4 -0
- package/types/pinyin/es/traditional.d.ts +4 -0
- package/types/snapdom/src/api/snapdom.d.ts +1 -0
- package/types/tree/index.d.ts +3 -4
- package/types/validate/src/index.d.ts +23 -25
- package/types/validate/src/interface.d.ts +5 -3
- package/types/validate/src/locale/en-US.d.ts +12 -2
- package/types/validate/src/locale/index.d.ts +171 -0
- package/types/validate/src/locale/zh-CN.d.ts +12 -2
- package/types/validate/src/rules/base.d.ts +3 -1
- package/types/validate/src/rules/custom.d.ts +1 -1
- package/types/validate/src/rules/type.d.ts +10 -0
- package/ui-color/compareColorByRange.js +1 -1
- package/ui-color/index.js +8 -7
- package/uiColor.js +25 -24
- package/url-toolkit/index.js +1 -1
- package/url-toolkit/src/url-toolkit.js +1 -1
- package/urlToolkit.js +1 -1
- package/validate/index.js +23 -25
- package/validate/src/index.js +116 -73
- package/validate/src/locale/en-US.js +12 -2
- package/validate/src/locale/index.js +11 -0
- package/validate/src/locale/zh-CN.js +12 -2
- package/validate/src/rules/array.js +2 -2
- package/validate/src/rules/base.js +35 -31
- package/validate/src/rules/boolean.js +1 -1
- package/validate/src/rules/custom.js +2 -2
- package/validate/src/rules/number.js +1 -1
- package/validate/src/rules/object.js +1 -1
- package/validate/src/rules/string.js +6 -5
- package/validate/src/rules/type.js +84 -14
- package/validate.js +23 -25
- package/version/index.js +1 -1
- package/version.js +1 -1
- package/xlsx/index.d.ts +4 -8
- package/xlsx/index.js +1 -1
- package/xlsx/xlsx.js +2 -2
- package/xlsx.js +1 -1
- package/types/validate/src/message.d.ts +0 -2
- package/types/validate/src/utils.d.ts +0 -3
- package/validate/src/message.js +0 -5
- package/validate/src/utils.js +0 -8
package/url-toolkit/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 2025-
|
|
1
|
+
/* 2025-12-17 18:26:57 */
|
|
2
2
|
const l = /^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^/?#]*)?))\2(?=((?:(?:[^?#/]*\/)*[^;?#/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/, p = /^(?=([^/?#]*))\1([^]*)$/, f = /(?:\/|^)\.(?=\/)/g, m = /(?:\/|^)\.\.\/(?!\.\.\/)[^/]*(?=\/)/g;
|
|
3
3
|
function E(r, a, s) {
|
|
4
4
|
if (s = s || {}, r = r.trim(), a = a.trim(), !a) {
|
package/urlToolkit.js
CHANGED
package/validate/index.js
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
/* 2025-
|
|
2
|
-
import {
|
|
3
|
-
import { default as
|
|
4
|
-
import { default as
|
|
5
|
-
import { default as u } from "./src/rules/
|
|
6
|
-
import { default as p
|
|
7
|
-
import { default as
|
|
1
|
+
/* 2025-12-17 18:26:57 */
|
|
2
|
+
import { PqbValidator as r, Validator as t, ValidatorSchema as e, Validator as l } from "./src/index.js";
|
|
3
|
+
import { default as f } from "./src/rules/array.js";
|
|
4
|
+
import { default as m } from "./src/rules/base.js";
|
|
5
|
+
import { default as u } from "./src/rules/boolean.js";
|
|
6
|
+
import { default as p } from "./src/rules/custom.js";
|
|
7
|
+
import { default as b } from "./src/locale/index.js";
|
|
8
8
|
import { default as n } from "./src/rules/number.js";
|
|
9
|
-
import { default as
|
|
10
|
-
import { default as
|
|
11
|
-
import { default as
|
|
12
|
-
import { mergeTemplate as T } from "./src/utils.js";
|
|
9
|
+
import { default as B } from "./src/rules/object.js";
|
|
10
|
+
import { default as g } from "./src/rules/string.js";
|
|
11
|
+
import { default as j } from "./src/rules/type.js";
|
|
13
12
|
export {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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/validate/src/index.js
CHANGED
|
@@ -1,106 +1,149 @@
|
|
|
1
|
-
/* 2025-
|
|
2
|
-
import
|
|
1
|
+
/* 2025-12-17 18:26:57 */
|
|
2
|
+
import g from "lodash/defaultsDeep.js";
|
|
3
3
|
import u from "lodash/isArray.js";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
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
|
|
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
|
|
50
|
+
import M from "./rules/number.js";
|
|
10
51
|
import O from "./rules/object.js";
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
20
|
-
|
|
59
|
+
p,
|
|
60
|
+
l.globalConfig
|
|
21
61
|
);
|
|
22
62
|
};
|
|
23
|
-
class
|
|
24
|
-
constructor(
|
|
25
|
-
const
|
|
26
|
-
...
|
|
63
|
+
class y {
|
|
64
|
+
constructor(t, a) {
|
|
65
|
+
const m = l.globalConfig, o = {
|
|
66
|
+
...m,
|
|
27
67
|
...a,
|
|
28
|
-
validateMessages:
|
|
29
|
-
|
|
30
|
-
a.validateMessages
|
|
68
|
+
validateMessages: g(
|
|
69
|
+
{},
|
|
70
|
+
a.validateMessages,
|
|
71
|
+
m.validateMessages
|
|
31
72
|
)
|
|
32
73
|
};
|
|
33
|
-
this.string = new
|
|
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
|
|
37
|
-
constructor(
|
|
38
|
-
this.schema =
|
|
77
|
+
class Ti {
|
|
78
|
+
constructor(t, a = {}) {
|
|
79
|
+
this.schema = t, this.options = a;
|
|
39
80
|
}
|
|
40
81
|
// 更新校验信息
|
|
41
|
-
messages(
|
|
82
|
+
messages(t) {
|
|
42
83
|
this.options = {
|
|
43
84
|
...this.options,
|
|
44
|
-
validateMessages:
|
|
45
|
-
|
|
46
|
-
|
|
85
|
+
validateMessages: g(
|
|
86
|
+
{},
|
|
87
|
+
t,
|
|
88
|
+
this.options.validateMessages
|
|
47
89
|
)
|
|
48
90
|
};
|
|
49
91
|
}
|
|
50
|
-
validate(
|
|
51
|
-
if (!
|
|
52
|
-
const
|
|
53
|
-
let
|
|
54
|
-
function
|
|
55
|
-
|
|
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(([
|
|
58
|
-
if (u(
|
|
59
|
-
for (
|
|
60
|
-
const
|
|
61
|
-
if (!
|
|
62
|
-
if (!
|
|
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
|
|
106
|
+
const c = {
|
|
65
107
|
...this.options,
|
|
66
|
-
message:
|
|
67
|
-
field:
|
|
108
|
+
message: b,
|
|
109
|
+
field: r
|
|
68
110
|
};
|
|
69
|
-
"ignoreEmptyString" in
|
|
70
|
-
const
|
|
71
|
-
let i =
|
|
72
|
-
if (!i) if (
|
|
73
|
-
i =
|
|
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:
|
|
77
|
-
}) : i &&
|
|
118
|
+
key: r
|
|
119
|
+
}) : i && f(r, i);
|
|
78
120
|
continue;
|
|
79
121
|
} else
|
|
80
|
-
i = d
|
|
81
|
-
if (Object.entries(
|
|
82
|
-
|
|
83
|
-
}), i.collect((
|
|
84
|
-
|
|
85
|
-
}),
|
|
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
|
-
}),
|
|
89
|
-
|
|
90
|
-
"error" in
|
|
91
|
-
}), a?.(
|
|
92
|
-
}) : a?.(
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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-
|
|
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}`",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 2025-
|
|
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-
|
|
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.
|
|
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-
|
|
2
|
-
import n from "lodash/
|
|
3
|
-
import f from "lodash/
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import c from "
|
|
8
|
-
import {
|
|
9
|
-
|
|
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 = (
|
|
12
|
-
const
|
|
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
|
-
}),
|
|
17
|
-
return
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
|
|
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(
|
|
25
|
+
return JSON.stringify(i);
|
|
23
26
|
} catch {
|
|
24
|
-
return
|
|
27
|
+
return String(i);
|
|
25
28
|
}
|
|
26
|
-
return String(
|
|
29
|
+
return String(i);
|
|
27
30
|
}
|
|
28
|
-
return
|
|
29
|
-
}) :
|
|
30
|
-
},
|
|
31
|
-
|
|
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.
|
|
40
|
+
return this.not_ = !this.not_, this;
|
|
37
41
|
}
|
|
38
42
|
get isRequired() {
|
|
39
|
-
if (g(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 || (
|
|
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 || (
|
|
61
|
+
message: this.message || (s(t) ? t : `${this.not_ ? "[NOT MODE]:" : ""}${t}`)
|
|
58
62
|
});
|
|
59
63
|
}
|
|
60
64
|
validate(t, e) {
|
|
61
|
-
return (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
|
-
|
|
72
|
+
q as default
|
|
69
73
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 2025-
|
|
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
|
-
|
|
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,7 +1,8 @@
|
|
|
1
|
-
/* 2025-
|
|
1
|
+
/* 2025-12-17 18:26:57 */
|
|
2
2
|
import i from "lodash/isString.js";
|
|
3
|
-
import s from "
|
|
4
|
-
|
|
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
|
|
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
|
-
|
|
54
|
+
o as default
|
|
54
55
|
};
|