Hyperlinkv0.8.0-beta.28

Schema

Schema.isMinPropertiesfunctioneffect/Schema.ts:8265
(
  minProperties: number,
  annotations?: Annotations.Filter
): SchemaAST.Filter<object>

Validates that an object contains at least the specified number of properties. This includes both string and symbol keys when counting properties.

Details

JSON Schema:

This check corresponds to the minProperties constraint in JSON Schema.

Arbitrary:

When generating test data with fast-check, this applies a node-local minLength constraint. Object generators interpret it as the final number of own properties.

Object checks
Source effect/Schema.ts:826520 lines
export function isMinProperties(minProperties: number, annotations?: Annotations.Filter) {
  minProperties = Math.max(0, Math.floor(minProperties))
  return makeFilter<object>(
    (input) => Reflect.ownKeys(input).length >= minProperties,
    {
      expected: `a value with at least ${minProperties === 1 ? "1 entry" : `${minProperties} entries`}`,
      meta: {
        _tag: "isMinProperties",
        minProperties
      },
      [SchemaAST.STRUCTURAL_ANNOTATION_KEY]: true,
      arbitrary: {
        constraint: {
          minLength: minProperties
        }
      },
      ...annotations
    }
  )
}
Referenced by 1 symbols