Hyperlinkv0.8.0-beta.28

Schema

Schema.isMinSizefunctioneffect/Schema.ts:8137
(minSize: number, annotations?: Annotations.Filter): SchemaAST.Filter<{
  readonly size: number
}>

Validates that a value has at least the specified size. Works with values that have a size property, such as Set or Map.

Details

JSON Schema:

This check does not have a direct JSON Schema equivalent, as it applies to values with a size property rather than standard JSON Schema types.

Arbitrary:

When generating test data with fast-check, this applies a node-local minLength constraint. Generators for values with a final .size, such as sets and maps, interpret it as final cardinality.

Size checks
Source effect/Schema.ts:813720 lines
export function isMinSize(minSize: number, annotations?: Annotations.Filter) {
  minSize = Math.max(0, Math.floor(minSize))
  return makeFilter<{ readonly size: number }>(
    (input) => input.size >= minSize,
    {
      expected: `a value with a size of at least ${minSize}`,
      meta: {
        _tag: "isMinSize",
        minSize
      },
      [SchemaAST.STRUCTURAL_ANNOTATION_KEY]: true,
      arbitrary: {
        constraint: {
          minLength: minSize
        }
      },
      ...annotations
    }
  )
}
Referenced by 1 symbols