@effect/schema
Advanced tools
Comparing version 0.33.2 to 0.34.0
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.ownKeys = exports.memoizeThunk = exports.getKeysForIndexSignature = exports.PrettyHookId = exports.ArbitraryHookId = void 0; | ||
exports.ownKeys = exports.minSafeInteger = exports.memoizeThunk = exports.maxSafeInteger = exports.getKeysForIndexSignature = exports.PrettyHookId = exports.ArbitraryHookId = void 0; | ||
/** | ||
@@ -40,2 +40,8 @@ * @since 1.0.0 | ||
exports.getKeysForIndexSignature = getKeysForIndexSignature; | ||
const maxSafeInteger = /*#__PURE__*/BigInt(Number.MAX_SAFE_INTEGER); | ||
/** @internal */ | ||
exports.maxSafeInteger = maxSafeInteger; | ||
const minSafeInteger = /*#__PURE__*/BigInt(Number.MIN_SAFE_INTEGER); | ||
/** @internal */ | ||
exports.minSafeInteger = minSafeInteger; | ||
const ownKeys = o => Object.keys(o).concat(Object.getOwnPropertySymbols(o)); | ||
@@ -42,0 +48,0 @@ /** @internal */ |
{ | ||
"name": "@effect/schema", | ||
"version": "0.33.2", | ||
"version": "0.34.0", | ||
"description": "Modeling the schema of data structures as first-class values", | ||
@@ -31,5 +31,5 @@ "license": "MIT", | ||
"peerDependencies": { | ||
"@effect/data": "^0.17.1", | ||
"@effect/io": "^0.38.0" | ||
"@effect/data": "^0.18.3", | ||
"@effect/io": "^0.39.0" | ||
} | ||
} |
@@ -482,2 +482,3 @@ <h3 align="center"> | ||
S.string.pipe(S.trimmed()); // verifies that a string contains no leading or trailing whitespaces | ||
S.string.pipe(S.lowercased()); // verifies that a string is lowercased | ||
``` | ||
@@ -1347,2 +1348,21 @@ | ||
#### Lowercase | ||
The `Lowercase` schema converts a string to lowercase. | ||
```ts | ||
import * as S from "@effect/schema/Schema"; | ||
// const schema: S.Schema<string, string> | ||
const schema = S.Lowercase; | ||
const parse = S.parseSync(schema); | ||
parse("A"); // "a" | ||
parse(" AB"); // " ab" | ||
parse("Ab "); // "ab " | ||
parse(" ABc "); // " abc " | ||
``` | ||
**Note**. If you were looking for a combinator to check if a string is lowercased, check out the `lowercased` combinator. | ||
#### ParseJson | ||
@@ -1443,2 +1463,29 @@ | ||
#### BigintFromNumber | ||
Transforms a `number` into a `bigint` by parsing the number using `BigInt`. | ||
```ts | ||
import * as S from "@effect/schema/Schema"; | ||
// const schema: S.Schema<number, bigint> | ||
const schema = S.BigintFromNumber; | ||
const parse = S.parseSync(schema); | ||
const encode = S.encodeSync(schema); | ||
// success cases | ||
parse(1); // 1n | ||
parse(-1); // -1n | ||
encode(1n); // 1 | ||
encode(-1n); // -1 | ||
// failure cases | ||
parse(1.5); // throws | ||
parse(NaN); // throws | ||
parse(Infinity); // throws | ||
parse(-Infinity); // throws | ||
encode(BigInt(Number.MAX_SAFE_INTEGER) + 1n); // throws | ||
encode(BigInt(Number.MIN_SAFE_INTEGER) - 1n); // throws | ||
``` | ||
#### clamp | ||
@@ -1445,0 +1492,0 @@ |
@@ -737,2 +737,22 @@ /** | ||
/** | ||
* This combinator transforms a `number` into a `bigint` by parsing the number using the `BigInt` function. | ||
* | ||
* It returns an error if the value can't be safely encoded as a `number` due to being out of range. | ||
* | ||
* @param self - The schema representing the input number | ||
* | ||
* @category bigint | ||
* @since 1.0.0 | ||
*/ | ||
export declare const bigintFromNumber: <I, A extends number>(self: Schema<I, A>) => Schema<I, bigint>; | ||
/** | ||
* This schema transforms a `number` into a `bigint` by parsing the number using the `BigInt` function. | ||
* | ||
* It returns an error if the value can't be safely encoded as a `number` due to being out of range. | ||
* | ||
* @category bigint | ||
* @since 1.0.0 | ||
*/ | ||
export declare const BigintFromNumber: Schema<number, bigint>; | ||
/** | ||
* Negates a boolean value | ||
@@ -1178,2 +1198,31 @@ * | ||
/** | ||
* @category type id | ||
* @since 1.0.0 | ||
*/ | ||
export declare const LowercasedTypeId = "@effect/schema/LowercasedTypeId"; | ||
/** | ||
* Verifies that a string is lowercased | ||
* | ||
* Note. This combinator does not make any transformations, it only validates. | ||
* If what you were looking for was a combinator to lowercase strings, then check out the `lowercase` combinator. | ||
* | ||
* @category string | ||
* @since 1.0.0 | ||
*/ | ||
export declare const lowercased: <A extends string>(options?: AnnotationOptions<A> | undefined) => <I>(self: Schema<I, A>) => Schema<I, A>; | ||
/** | ||
* This combinator converts a string to lowercase | ||
* | ||
* @category string | ||
* @since 1.0.0 | ||
*/ | ||
export declare const lowercase: <I, A extends string>(self: Schema<I, A>) => Schema<I, A>; | ||
/** | ||
* This combinator converts a string to lowercase | ||
* | ||
* @category string | ||
* @since 1.0.0 | ||
*/ | ||
export declare const Lowercase: Schema<string, string>; | ||
/** | ||
* This schema allows removing whitespaces from the beginning and end of a string. | ||
@@ -1180,0 +1229,0 @@ * |
@@ -42,2 +42,8 @@ /** | ||
/** @internal */ | ||
export const maxSafeInteger = BigInt(Number.MAX_SAFE_INTEGER) | ||
/** @internal */ | ||
export const minSafeInteger = BigInt(Number.MIN_SAFE_INTEGER) | ||
/** @internal */ | ||
export const ownKeys = (o: object): ReadonlyArray<PropertyKey> => | ||
@@ -44,0 +50,0 @@ (Object.keys(o) as ReadonlyArray<PropertyKey>).concat(Object.getOwnPropertySymbols(o)) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
972072
18306
1892