MCPcopy Create free account
hub / github.com/Effect-TS/effect / isMinLength

Function isMinLength

packages/effect/src/Schema.ts:8805–8826  ·  view source on GitHub ↗
(minLength: number, annotations?: Annotations.Filter)

Source from the content-addressed store, hash-verified

8803 * @since 4.0.0
8804 */
8805export function isMinLength(minLength: number, annotations?: Annotations.Filter) {
8806 minLength = Math.max(0, Math.floor(minLength))
8807 return makeFilter<{ readonly length: number }>(
8808 (input) => input.length >= minLength,
8809 {
8810 expected: `a value with a length of at least ${minLength}`,
8811 representation: {
8812 id: "effect/schema/isMinLength",
8813 payload: { minLength }
8814 },
8815 toJsonSchema: ({ type }) => type === "array" ? { minItems: minLength } : { minLength },
8816 toCode: () => ({ runtime: `Schema.isMinLength(${minLength})` }),
8817 [InternalAnnotations.STRUCTURAL_ANNOTATION_KEY]: true,
8818 arbitrary: {
8819 constraint: {
8820 minLength
8821 }
8822 },
8823 ...annotations
8824 }
8825 )
8826}
8827
8828/**
8829 * Reviver for persisted `isMinLength` checks.

Callers 2

Schema.tsFile · 0.85
isNonEmptyFunction · 0.85

Calls 1

makeFilterFunction · 0.85

Tested by

no test coverage detected