(minLength: number, annotations?: Annotations.Filter)
| 8803 | * @since 4.0.0 |
| 8804 | */ |
| 8805 | export 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. |
no test coverage detected