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

Function isMaxProperties

packages/effect/src/Schema.ts:9283–9304  ·  view source on GitHub ↗
(maxProperties: number, annotations?: Annotations.Filter)

Source from the content-addressed store, hash-verified

9281 * @since 4.0.0
9282 */
9283export function isMaxProperties(maxProperties: number, annotations?: Annotations.Filter) {
9284 maxProperties = Math.max(0, Math.floor(maxProperties))
9285 return makeFilter<object>(
9286 (input) => Reflect.ownKeys(input).length <= maxProperties,
9287 {
9288 expected: `a value with at most ${maxProperties === 1 ? "1 entry" : `${maxProperties} entries`}`,
9289 representation: {
9290 id: "effect/schema/isMaxProperties",
9291 payload: { maxProperties }
9292 },
9293 toJsonSchema: () => ({ maxProperties }),
9294 toCode: () => ({ runtime: `Schema.isMaxProperties(${maxProperties})` }),
9295 [InternalAnnotations.STRUCTURAL_ANNOTATION_KEY]: true,
9296 arbitrary: {
9297 constraint: {
9298 maxLength: maxProperties
9299 }
9300 },
9301 ...annotations
9302 }
9303 )
9304}
9305
9306/**
9307 * Reviver for persisted `isMaxProperties` checks.

Callers 1

Schema.tsFile · 0.85

Calls 1

makeFilterFunction · 0.85

Tested by

no test coverage detected