effect-io-ai

Package: effect
Module: Schema

Schema.OptionFromNonEmptyTrimmedString

Transforms strings into an Option type, effectively filtering out empty or whitespace-only strings by trimming them and checking their length. Returns none for invalid inputs and some for valid non-empty strings.

Example

import { Schema } from "effect"

console.log(Schema.decodeSync(Schema.OptionFromNonEmptyTrimmedString)("")) // Option.none()
console.log(Schema.decodeSync(Schema.OptionFromNonEmptyTrimmedString)(" a ")) // Option.some("a")
console.log(Schema.decodeSync(Schema.OptionFromNonEmptyTrimmedString)("a")) // Option.some("a")

Signature

declare class OptionFromNonEmptyTrimmedString

Source

Since v3.10.0