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

Function isUnique

packages/effect/src/Schema.ts:9479–9498  ·  view source on GitHub ↗
(annotations?: Annotations.Filter)

Source from the content-addressed store, hash-verified

9477 * @since 4.0.0
9478 */
9479export function isUnique<T>(annotations?: Annotations.Filter) {
9480 return makeFilter<ReadonlyArray<T>>(
9481 (input) => Arr.dedupe(input).length === input.length,
9482 {
9483 expected: "an array with unique items",
9484 representation: {
9485 id: "effect/schema/isUnique",
9486 payload: null
9487 },
9488 toJsonSchema: () => ({ uniqueItems: true }),
9489 toCode: () => ({ runtime: "Schema.isUnique()" }),
9490 arbitrary: {
9491 constraint: {
9492 unique: true
9493 }
9494 },
9495 ...annotations
9496 }
9497 )
9498}
9499
9500/**
9501 * Reviver for persisted `isUnique` checks.

Callers 2

UniqueArrayFunction · 0.85
Schema.tsFile · 0.85

Calls 1

makeFilterFunction · 0.85

Tested by

no test coverage detected