@aomex/core
Advanced tools
Comparing version 1.5.1 to 1.6.0
@@ -6,2 +6,10 @@ # Change Log | ||
# [1.6.0](https://github.com/aomex/aomex/compare/v1.5.1...v1.6.0) (2024-07-05) | ||
**Note:** Version bump only for package @aomex/core | ||
## [1.5.1](https://github.com/aomex/aomex/compare/v1.5.0...v1.5.1) (2024-07-04) | ||
@@ -8,0 +16,0 @@ |
@@ -691,5 +691,4 @@ import { OpenAPIV3 } from 'openapi-types'; | ||
declare const versions: readonly ["v4", "v6"]; | ||
declare namespace IpValidator { | ||
type Version = (typeof versions)[number]; | ||
type Version = 'v4' | 'v6'; | ||
interface Options<T> extends BaseStringValidator.Options<T> { | ||
@@ -700,5 +699,2 @@ ipVersion: IpValidator.Version[]; | ||
declare class IpValidator<T = string> extends BaseStringValidator<T> { | ||
static patterns: { | ||
[key in IpValidator.Version | 'all']: RegExp; | ||
}; | ||
protected config: IpValidator.Options<T>; | ||
@@ -705,0 +701,0 @@ constructor(version: IpValidator.Version[]); |
@@ -1041,11 +1041,4 @@ // src/i18n/i18n-message.ts | ||
// src/validator/validators/ip.ts | ||
import ipRegexp from "ip-regex"; | ||
var versions = ["v4", "v6"]; | ||
var options = { exact: true, includeBoundaries: true }; | ||
var IpValidator = class _IpValidator extends BaseStringValidator { | ||
static patterns = { | ||
v4: ipRegexp.v4(options), | ||
v6: ipRegexp.v6(options), | ||
all: ipRegexp(options) | ||
}; | ||
import { isIP, isIPv4, isIPv6 } from "node:net"; | ||
var IpValidator = class extends BaseStringValidator { | ||
constructor(version) { | ||
@@ -1058,11 +1051,10 @@ super(); | ||
let valid = false; | ||
if (ipVersion.length === versions.length) { | ||
valid = _IpValidator.patterns.all.test(ip); | ||
const hasV4 = ipVersion.includes("v4"); | ||
const hasV6 = ipVersion.includes("v6"); | ||
if (hasV4 && hasV6) { | ||
valid = isIP(ip) > 0; | ||
} else if (hasV4) { | ||
valid = isIPv4(ip); | ||
} else { | ||
for (let i = ipVersion.length; i-- > 0; ) { | ||
if (_IpValidator.patterns[ipVersion[i]].test(ip)) { | ||
valid = true; | ||
break; | ||
} | ||
} | ||
valid = isIPv6(ip); | ||
} | ||
@@ -1326,5 +1318,5 @@ if (!valid) { | ||
}; | ||
constructor(versions2) { | ||
constructor(versions) { | ||
super(); | ||
this.config.uuidVersion = [...new Set(versions2)]; | ||
this.config.uuidVersion = [...new Set(versions)]; | ||
} | ||
@@ -1480,4 +1472,4 @@ validateString(uuid, _key, label) { | ||
} | ||
uuid(versions2) { | ||
return new UuidValidator(toArray(versions2)); | ||
uuid(versions) { | ||
return new UuidValidator(toArray(versions)); | ||
} | ||
@@ -1488,4 +1480,4 @@ }; | ||
// src/validator/api/validate.ts | ||
var validate = async (untrusted, validators, options2 = {}) => { | ||
const { errorFormatter = defaultErrorFormatter } = options2; | ||
var validate = async (untrusted, validators, options = {}) => { | ||
const { errorFormatter = defaultErrorFormatter } = options; | ||
const validator = toValidator(validators); | ||
@@ -1492,0 +1484,0 @@ const source = await untrusted; |
{ | ||
"name": "@aomex/core", | ||
"version": "1.5.1", | ||
"version": "1.6.0", | ||
"description": "aomex核心库", | ||
@@ -37,7 +37,6 @@ "type": "module", | ||
"email-validator": "^2.0.4", | ||
"ip-regex": "^5.0.0", | ||
"openapi-types": "^12.1.3", | ||
"@aomex/internal-tools": "^1.5.1" | ||
"@aomex/internal-tools": "^1.6.0" | ||
}, | ||
"scripts": {} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5
198757
2508
- Removedip-regex@^5.0.0
- Removedip-regex@5.0.0(transitive)
Updated@aomex/internal-tools@^1.6.0