UNPKG

the-moby-effect

Version:
57 lines 1.64 kB
/** * IPv4 or IPv6 addresses schema. * * @since 1.0.0 */ import * as Schema from "effect/Schema"; import * as IPv4 from "./ipv4.js"; import * as IPv6 from "./ipv6.js"; /** * An IP address in string format, which is either an IPv4 or IPv6 address. * * @since 1.0.0 * @category Schemas */ export const AddressString = /*#__PURE__*/Schema.Union(IPv4.IPv4String, IPv6.IPv6String).annotations({ identifier: "AddressString", description: "An ipv4 or ipv6 address in string format" }); /** * An IP address, which is either an IPv4 or IPv6 address. * * @since 1.0.0 * @category Schemas * @example * import * as Schema from "effect/Schema"; * import { Address } from "the-moby-effect/schemas/index.js"; * * const decodeAddress = Schema.decodeSync(Address); * * assert.throws(() => decodeAddress("1.1.b.1")); * assert.throws(() => * decodeAddress("2001:0db8:85a3:0000:0000:8a2e:0370:7334:") * ); * * assert.doesNotThrow(() => decodeAddress("1.1.1.2")); * assert.doesNotThrow(() => * decodeAddress("2001:0db8:85a3:0000:0000:8a2e:0370:7334") * ); * * @see {@link IPv4.IPv4} * @see {@link IPv6.IPv6} */ export const Address = /*#__PURE__*/Schema.Union(IPv4.IPv4, IPv6.IPv6).annotations({ identifier: "Address", description: "An ipv4 or ipv6 address" }); /** * An IP address as a bigint. * * @since 1.0.0 * @category Schemas */ export const AddressBigint = /*#__PURE__*/Schema.Union(IPv4.IPv4Bigint, IPv6.IPv6Bigint).annotations({ identifier: "AddressBigint", description: "An ipv4 or ipv6 address as a bigint" }); //# sourceMappingURL=address.js.map