( self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>> )
| 5312 | * @since 3.10.0 |
| 5313 | */ |
| 5314 | export function parseNumber<S extends Schema.Any, A extends string>( |
| 5315 | self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>> |
| 5316 | ): transformOrFail<S, typeof Number$> { |
| 5317 | return transformOrFail( |
| 5318 | self, |
| 5319 | Number$, |
| 5320 | { |
| 5321 | strict: false, |
| 5322 | decode: (i, _, ast) => |
| 5323 | ParseResult.fromOption( |
| 5324 | number_.parse(i), |
| 5325 | () => new ParseResult.Type(ast, i, `Unable to decode ${JSON.stringify(i)} into a number`) |
| 5326 | ), |
| 5327 | encode: (a) => ParseResult.succeed(String(a)) |
| 5328 | } |
| 5329 | ) |
| 5330 | } |
| 5331 | |
| 5332 | /** |
| 5333 | * This schema transforms a `string` into a `number` by parsing the string using the `parse` function of the `effect/Number` module. |
no test coverage detected