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

Function isSizeBetween

packages/effect/src/Schema.ts:9152–9178  ·  view source on GitHub ↗
(minimum: number, maximum: number, annotations?: Annotations.Filter)

Source from the content-addressed store, hash-verified

9150 * @since 4.0.0
9151 */
9152export function isSizeBetween(minimum: number, maximum: number, annotations?: Annotations.Filter) {
9153 minimum = Math.max(0, Math.floor(minimum))
9154 maximum = Math.max(0, Math.floor(maximum))
9155 return makeFilter<{ readonly size: number }>(
9156 (input) => input.size >= minimum && input.size <= maximum,
9157 {
9158 expected: minimum === maximum
9159 ? `a value with a size of ${minimum}`
9160 : `a value with a size between ${minimum} and ${maximum}`,
9161
9162 representation: {
9163 id: "effect/schema/isSizeBetween",
9164 payload: { minimum, maximum }
9165 },
9166 toJsonSchema: () => ({}),
9167 toCode: () => ({ runtime: `Schema.isSizeBetween(${minimum}, ${maximum})` }),
9168 [InternalAnnotations.STRUCTURAL_ANNOTATION_KEY]: true,
9169 arbitrary: {
9170 constraint: {
9171 minLength: minimum,
9172 maxLength: maximum
9173 }
9174 },
9175 ...annotations
9176 }
9177 )
9178}
9179
9180/**
9181 * Reviver for persisted `isSizeBetween` checks.

Callers 1

Schema.tsFile · 0.85

Calls 1

makeFilterFunction · 0.85

Tested by

no test coverage detected