(annotations?: Annotations.Filter): SchemaAST.Filter<{
readonly length: number
}>Validates that a value has at least one element. Works with strings and arrays.
This is equivalent to isMinLength(1).
Details
JSON Schema:
This check corresponds to the minLength: 1 constraint for strings or the
minItems: 1 constraint for arrays in JSON Schema.
Arbitrary:
When generating test data with fast-check, this applies a minLength: 1
constraint to ensure generated strings or arrays are non-empty.
export function function isNonEmpty(
annotations?: Annotations.Filter
): SchemaAST.Filter<{
readonly length: number
}>
Validates that a value has at least one element. Works with strings and arrays.
This is equivalent to isMinLength(1).
Details
JSON Schema:
This check corresponds to the minLength: 1 constraint for strings or the
minItems: 1 constraint for arrays in JSON Schema.
Arbitrary:
When generating test data with fast-check, this applies a minLength: 1
constraint to ensure generated strings or arrays are non-empty.
isNonEmpty(annotations: Annotations.Filter | undefinedannotations?: Annotations.interface Annotations.FilterAnnotations for filter schema nodes (created via Schema.filter). Extends
Augment
with an optional error message, identifier, and metadata.
Filters are intentionally non-parametric to keep them covariant.
Filter) {
return function isMinLength(
minLength: number,
annotations?: Annotations.Filter
): SchemaAST.Filter<{
readonly length: number
}>
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))
isMinLength(1, annotations: Annotations.Filter | undefinedannotations)
}