effect-io-ai

Package: effect
Module: Schema

Schema.isMinLength

Validates that a value has at least the specified length. Works with strings and arrays.

Details

JSON Schema:

This check corresponds to the minLength constraint for strings or the minItems constraint for arrays in JSON Schema.

Arbitrary:

When generating test data with fast-check, this applies a minLength constraint to ensure generated strings or arrays have at least the required length.

Example (Checking minimum length)

import { Schema } from "effect"

const NonEmptyStringSchema = Schema.String.check(Schema.isMinLength(1))
const NonEmptyArraySchema = Schema.Array(Schema.Number).check(Schema.isMinLength(1))

Signature

declare const isMinLength: (minLength: number, annotations?: Annotations.Filter) => SchemaAST.Filter<{ readonly length: number; }>

Source

Since v4.0.0