<A extends Brand<any>>(
filter: (unbranded: Brand.Unbranded<A>) => Schema.FilterOutput
): Constructor<A>Returns a Constructor that can construct a branded type from an unbranded
value using the provided filter predicate as validation of the input data.
When to use
Use when you want validation while constructing the branded type.
export function function make<A extends Brand<any>>(
filter: (
unbranded: Brand.Unbranded<A>
) => Schema.FilterOutput
): Constructor<A>
Returns a Constructor that can construct a branded type from an unbranded
value using the provided filter predicate as validation of the input data.
When to use
Use when you want validation while constructing the branded type.
make<function (type parameter) A in make<A extends Brand<any>>(filter: (unbranded: Brand.Unbranded<A>) => Schema.FilterOutput): Constructor<A>A extends interface Brand<in out Keys extends string>A generic interface that defines a branded type.
When to use
Use to define a branded type such as number & Brand<"Positive"> when
TypeScript should keep structurally identical values separate without
changing their runtime value.
Namespace containing type-level helpers for working with branded types and
brand constructors.
Brand<any>>(
filter: (
unbranded: Brand.Unbranded<A>
) => Schema.FilterOutput
filter: (unbranded: Brand.Unbranded<A>unbranded: Brand.type Brand<in out Keys extends string>.Unbranded<B extends Brand<any>> = B extends infer U & Types.UnionToIntersection<{ [K in keyof B["~effect/Brand"]]: K extends string ? Brand<K> : never; }[keyof B["~effect/Brand"]]> ? U : BA utility type to extract the unbranded value type from a brand.
Unbranded<function (type parameter) A in make<A extends Brand<any>>(filter: (unbranded: Brand.Unbranded<A>) => Schema.FilterOutput): Constructor<A>A>) => import SchemaSchema.type FilterOutput =
| boolean
| Schema.FilterIssue
| readonly Schema.FilterIssue[]
| undefined
The value a filter predicate (see
makeFilter
) may return.
Details
Each shape is normalized into an
SchemaIssue.Issue
(or undefined for
success) before being attached to the parse result:
undefined: success. The input satisfies the filter.
true: success. Equivalent to undefined, useful when the predicate is
a plain boolean expression.
false: generic failure. Produces an
SchemaIssue.InvalidValue
wrapping
the input, with no custom message.
FilterIssue
: a single failure. See
FilterIssue
for the
shapes (string,
SchemaIssue.Issue
, or { path, issue }).
ReadonlyArray<FilterIssue>: several failures reported together. An
empty array is treated as success; a single-element array is equivalent
to returning that element directly; otherwise the entries are grouped
into an
SchemaIssue.Composite
.
FilterOutput
): interface Constructor<in out B extends Brand<any>>A constructor for a branded type that provides validation and safe
construction methods.
When to use
Use as the shared callable interface for branded values when an API accepts
or returns a brand constructor and callers need throwing, Option, Result,
or type-guard validation forms.
Constructor<function (type parameter) A in make<A extends Brand<any>>(filter: (unbranded: Brand.Unbranded<A>) => Schema.FilterOutput): Constructor<A>A> {
return function check<A extends Brand<any>>(
checks_0: SchemaAST.Check<Brand.Unbranded<A>>,
...checks: Array<
SchemaAST.Check<Brand.Unbranded<A>>
>
): Constructor<A>
Creates a branded type Constructor from one or more schema checks.
When to use
Use when you need a branded type constructor that performs runtime validation
via schema checks.
Details
Calling the returned constructor validates the unbranded value and throws on
failure. Use the returned option, result, or is methods for
non-throwing validation.
check(import SchemaASTSchemaAST.function makeFilter<T>(
filter: (
input: T,
ast: AST,
options: ParseOptions
) => Schema.FilterOutput,
annotations?:
| Schema.Annotations.Filter
| undefined,
aborted?: boolean
): Filter<T>
makeFilter(filter: (
unbranded: Brand.Unbranded<A>
) => Schema.FilterOutput
filter))
}