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

Function isMaxCodePoints

packages/effect/src/Schema.ts:8719–8734  ·  view source on GitHub ↗
(maxCodePoints: number, annotations?: Annotations.Filter)

Source from the content-addressed store, hash-verified

8717 * @since 4.0.0
8718 */
8719export function isMaxCodePoints(maxCodePoints: number, annotations?: Annotations.Filter) {
8720 maxCodePoints = normalizeCardinality(maxCodePoints)
8721 return makeFilter<string>(
8722 (input) => countCodePointsUpTo(input, maxCodePoints + 1) <= maxCodePoints,
8723 {
8724 expected: `a string with at most ${maxCodePoints} code points`,
8725 representation: {
8726 id: "effect/schema/isMaxCodePoints",
8727 payload: { maxCodePoints }
8728 },
8729 toJsonSchema: () => ({ maxLength: maxCodePoints }),
8730 arbitraryConstraint: { maxCodePoints },
8731 ...annotations
8732 }
8733 )
8734}
8735/**
8736 * Validates that a string's Unicode code point count is within the specified inclusive range.
8737 *

Callers

nothing calls this directly

Calls 3

normalizeCardinalityFunction · 0.85
countCodePointsUpToFunction · 0.85
makeFilterFunction · 0.70

Tested by

no test coverage detected