(u: unknown): u is PrimaryKeyChecks whether a value implements the PrimaryKey protocol.
When to use
Use to narrow an unknown value before treating it as a PrimaryKey.
Details
This is a structural guard for the PrimaryKey.symbol property.
Gotchas
This guard does not call the method or verify that it returns a string.
export const const isPrimaryKey: (
u: unknown
) => u is PrimaryKey
Checks whether a value implements the PrimaryKey protocol.
When to use
Use to narrow an unknown value before treating it as a PrimaryKey.
Details
This is a structural guard for the PrimaryKey.symbol property.
Gotchas
This guard does not call the method or verify that it returns a string.
isPrimaryKey = (u: unknownu: unknown): u: unknownu is PrimaryKey => hasProperty<"~effect/interfaces/PrimaryKey">(self: unknown, property: "~effect/interfaces/PrimaryKey"): self is { [K in "~effect/interfaces/PrimaryKey"]: unknown; } (+1 overload)Checks whether a value has a given property key.
When to use
Use when you need a Predicate guard for property access on unknown
values with a simple structural object check.
Details
Uses the in operator and isObjectKeyword. This does not check property
value types.
Example (Guarding object properties)
import { Predicate } from "effect"
const hasName = Predicate.hasProperty("name")
const data: unknown = { name: "Ada" }
if (hasName(data)) {
console.log(data.name)
}
hasProperty(u: unknownu, const symbol: "~effect/interfaces/PrimaryKey"Defines the unique identifier used to identify objects that implement the PrimaryKey interface.
When to use
Use to implement the PrimaryKey protocol as a computed property key on
classes or object literals that expose a stable string identifier.
symbol)