@effect/schema
Advanced tools
Comparing version 0.30.3 to 0.30.4
{ | ||
"name": "@effect/schema", | ||
"version": "0.30.3", | ||
"version": "0.30.4", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -986,2 +986,11 @@ <h3 align="center"> | ||
## Compose | ||
The `compose` combinator allows you to combine two schemas. | ||
```ts | ||
// $ExpectType Schema<string, readonly number[]> | ||
S.compose(S.split(S.string, ","), S.array(S.NumberFromString)); | ||
``` | ||
## InstanceOf | ||
@@ -1162,2 +1171,19 @@ | ||
#### split | ||
The `split` combinator allows splitting a string into an array of strings. | ||
```ts | ||
import * as S from "@effect/schema/Schema"; | ||
// const schema: S.Schema<string, string> | ||
const schema = S.string.pipe(S.split(",")); | ||
const parse = S.parseSync(schema); | ||
parse(""); // [""] | ||
parse(","); // ["", ""] | ||
parse("a,"); // ["a", ""] | ||
parse("a,b"); // ["a", "b"] | ||
``` | ||
#### Trim | ||
@@ -1227,2 +1253,25 @@ | ||
#### BigintFromString | ||
Transforms a `string` into a `bigint` by parsing the string using `BigInt`. | ||
```ts | ||
import * as S from "@effect/schema/Schema"; | ||
// const schema: S.Schema<string, bigint> | ||
const schema = S.BigintFromString; | ||
const parse = S.parseSync(schema); | ||
// success cases | ||
parse("1"); // 1n | ||
parse("-1"); // -1n | ||
// failure cases | ||
parse("a"); // throws | ||
parse("1.5"); // throws | ||
parse("NaN"); // throws | ||
parse("Infinity"); // throws | ||
parse("-Infinity"); // throws | ||
``` | ||
#### clamp | ||
@@ -1229,0 +1278,0 @@ |
@@ -384,2 +384,10 @@ /** | ||
*/ | ||
export declare const compose: { | ||
<B, C>(bc: Schema<B, C>): <A>(ab: Schema<A, B>) => Schema<A, C>; | ||
<A, B, C>(ab: Schema<A, B>, bc: Schema<B, C>): Schema<A, C>; | ||
}; | ||
/** | ||
* @category combinators | ||
* @since 1.0.0 | ||
*/ | ||
export declare const lazy: <I, A = I>(f: () => Schema<I, A>, annotations?: AST.Annotated["annotations"]) => Schema<I, A>; | ||
@@ -658,2 +666,22 @@ /** | ||
/** | ||
* This combinator transforms a `string` into a `bigint` by parsing the string using the `BigInt` function. | ||
* | ||
* It returns an error if the value can't be converted (for example when non-numeric characters are provided). | ||
* | ||
* @param self - The schema representing the input string | ||
* | ||
* @category bigint | ||
* @since 1.0.0 | ||
*/ | ||
export declare const bigintFromString: <I, A extends string>(self: Schema<I, A>) => Schema<I, bigint>; | ||
/** | ||
* This schema transforms a `string` into a `bigint` by parsing the string using the `BigInt` function. | ||
* | ||
* It returns an error if the value can't be converted (for example when non-numeric characters are provided). | ||
* | ||
* @category bigint | ||
* @since 1.0.0 | ||
*/ | ||
export declare const BigintFromString: Schema<string, bigint>; | ||
/** | ||
* Negates a boolean value | ||
@@ -1106,2 +1134,12 @@ * | ||
/** | ||
* This combinator allows splitting a string into an array of strings. | ||
* | ||
* @category string | ||
* @since 1.0.0 | ||
*/ | ||
export declare const split: { | ||
(separator: string): <I>(self: Schema<I, string>) => Schema<I, ReadonlyArray<string>>; | ||
<I>(self: Schema<I, string>, separator: string): Schema<I, ReadonlyArray<string>>; | ||
}; | ||
/** | ||
* @category type id | ||
@@ -1108,0 +1146,0 @@ * @since 1.0.0 |
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
930588
17625
1678