Doubter - v5.1.1-next.e4e15ab
    Preparing search index...

    Interface NotShape<BaseShape, ExcludedShape>

    Shortcut for ExcludeShape that doesn't impose the exclusion on the type level.

    interface NotShape<BaseShape extends AnyShape, ExcludedShape extends AnyShape> {
        annotations: Dict;
        baseShape: BaseShape;
        excludedShape: ExcludedShape;
        inputs: readonly unknown[];
        isAsync: boolean;
        operations: readonly Operation[];
        _apply(
            input: unknown,
            options: ParseOptions,
            _nonce: number,
        ): Result<Output<BaseShape>>;
        _applyAsync(
            input: unknown,
            options: ParseOptions,
            nonce: number,
        ): Promise<Result<Output<BaseShape>>>;
        _applyOperations(
            input: unknown,
            output: unknown,
            options: ParseOptions,
            issues: null | Issue[],
        ): Result | Promise<Result>;
        _clone(): this;
        _getInputs(): readonly unknown[];
        _isAsync(): boolean;
        accepts(input: unknown): boolean;
        addAsyncOperation<Param>(
            cb: OperationCallback<
                PromiseLike<Result<Output<BaseShape>>>,
                Output<BaseShape>,
                Param,
            >,
            options?: ParameterizedOperationOptions<Param>,
        ): this;
        addAsyncOperation(
            cb: OperationCallback<
                PromiseLike<Result<Output<BaseShape>>>,
                Output<BaseShape>,
            >,
            options?: OperationOptions,
        ): this;
        addOperation<Param>(
            cb: OperationCallback<
                Result<Output<BaseShape>>,
                Output<BaseShape>,
                Param,
            >,
            options?: ParameterizedOperationOptions<Param>,
        ): this;
        addOperation(
            cb: OperationCallback<Result<Output<BaseShape>>, Output<BaseShape>>,
            options?: OperationOptions,
        ): this;
        allow<AllowedValue extends Any>(
            value: AllowedValue,
        ): AllowShape<NotShape<BaseShape, ExcludedShape>, AllowedValue>;
        alter<Param>(
            cb: OperationCallback<Output<BaseShape>, Output<BaseShape>, Param>,
            options: ParameterizedOperationOptions<Param>,
        ): this;
        alter(
            cb: OperationCallback<Output<BaseShape>, Output<BaseShape>>,
            options?: OperationOptions,
        ): this;
        alterAsync<Param>(
            cb: OperationCallback<
                PromiseLike<Output<BaseShape>>,
                Output<BaseShape>,
                Param,
            >,
            options: ParameterizedOperationOptions<Param>,
        ): this;
        alterAsync(
            cb: OperationCallback<
                PromiseLike<Output<BaseShape>>,
                Output<BaseShape>,
            >,
            options?: OperationOptions,
        ): this;
        annotate(annotations: ReadonlyDict): this;
        at(_key: unknown): null | AnyShape;
        brand<Brand extends string | number | symbol>(): RefineShape<
            NotShape<BaseShape, ExcludedShape>,
            Branded<Output<BaseShape>, Brand>,
        >;
        catch(): CatchShape<NotShape<BaseShape, ExcludedShape>, undefined>;
        catch<FallbackValue extends Any>(
            fallback:
                | FallbackValue
                | ((input: any, issues: Issue[], options: ParseOptions) => FallbackValue),
        ): CatchShape<NotShape<BaseShape, ExcludedShape>, FallbackValue>;
        check<Param>(
            cb: OperationCallback<CheckResult, Output<BaseShape>, Param>,
            options: ParameterizedOperationOptions<Param>,
        ): this;
        check(
            cb: OperationCallback<CheckResult, Output<BaseShape>>,
            options?: OperationOptions,
        ): this;
        checkAsync<Param>(
            cb: OperationCallback<
                PromiseLike<CheckResult>,
                Output<BaseShape>,
                Param,
            >,
            options: ParameterizedOperationOptions<Param>,
        ): this;
        checkAsync(
            cb: OperationCallback<PromiseLike<CheckResult>, Output<BaseShape>>,
            options?: OperationOptions,
        ): this;
        convert<ConvertedValue>(
            cb: (value: Output, options: ParseOptions) => ConvertedValue,
        ): Shape<Input<BaseShape>, ConvertedValue>;
        convertAsync<ConvertedValue>(
            cb: (
                value: Output,
                options: ParseOptions,
            ) => PromiseLike<ConvertedValue>,
        ): Shape<Input<BaseShape>, ConvertedValue>;
        deepPartial(): NotShape;
        deny<DeniedValue extends any>(
            value: DeniedValue,
            options?: IssueOptions | Message,
        ): DenyShape<NotShape<BaseShape, ExcludedShape>, DeniedValue>;
        exclude<ExcludedShape extends AnyShape>(
            shape: ExcludedShape,
            options?: IssueOptions | Message,
        ): ExcludeShape<NotShape<BaseShape, ExcludedShape>, ExcludedShape>;
        nonOptional(
            options?: IssueOptions | Message,
        ): DenyShape<NotShape<BaseShape, ExcludedShape>, undefined>;
        not<ExcludedShape extends AnyShape>(
            shape: ExcludedShape,
            options?: IssueOptions | Message,
        ): NotShape<NotShape<BaseShape, ExcludedShape>, ExcludedShape>;
        nullable(): AllowShape<NotShape<BaseShape, ExcludedShape>, null>;
        nullable<DefaultValue extends Any>(
            defaultValue: DefaultValue,
        ): ReplaceShape<NotShape<BaseShape, ExcludedShape>, null, DefaultValue>;
        nullish(): AllowShape<
            AllowShape<NotShape<BaseShape, ExcludedShape>, null>,
            undefined,
        >;
        nullish<DefaultValue extends Any>(
            defaultValue?: DefaultValue,
        ): ReplaceShape<
            ReplaceShape<NotShape<BaseShape, ExcludedShape>, null, DefaultValue>,
            undefined,
            DefaultValue,
        >;
        optional(): AllowShape<NotShape<BaseShape, ExcludedShape>, undefined>;
        optional<DefaultValue extends Any>(
            defaultValue: DefaultValue,
        ): ReplaceShape<
            NotShape<BaseShape, ExcludedShape>,
            undefined,
            DefaultValue,
        >;
        parse(input: unknown, options?: ParseOptions): Output;
        parseAsync(
            input: unknown,
            options?: ParseOptions,
        ): Promisify<Output<BaseShape>>;
        parseOrDefault(input: unknown): undefined | Output<BaseShape>;
        parseOrDefault<DefaultValue>(
            input: unknown,
            defaultValue: DefaultValue,
            options?: ParseOptions,
        ): Output<BaseShape> | DefaultValue;
        parseOrDefaultAsync(
            input: unknown,
        ): Promisify<undefined | Output<BaseShape>>;
        parseOrDefaultAsync<DefaultValue>(
            input: unknown,
            defaultValue: DefaultValue,
            options?: ParseOptions,
        ): Promisify<Output<BaseShape> | DefaultValue>;
        refine<RefinedValue extends any, Param>(
            cb: RefinePredicate<Output<BaseShape>, RefinedValue, Param>,
            options: Message | ParameterizedRefineOptions<Param>,
        ): RefineShape<NotShape<BaseShape, ExcludedShape>, RefinedValue>;
        refine<RefinedValue extends any>(
            cb: RefinePredicate<Output<BaseShape>, RefinedValue>,
            options?: Message | RefineOptions,
        ): RefineShape<NotShape<BaseShape, ExcludedShape>, RefinedValue>;
        refine<Param>(
            cb: OperationCallback<unknown, Output<BaseShape>, Param>,
            options?: Message | ParameterizedRefineOptions<Param>,
        ): this;
        refine(
            cb: OperationCallback<unknown, Output<BaseShape>>,
            options?: Message | RefineOptions,
        ): this;
        refineAsync<Param>(
            cb: OperationCallback<PromiseLike<unknown>, Output<BaseShape>, Param>,
            options?: Message | ParameterizedRefineOptions<Param>,
        ): this;
        refineAsync(
            cb: OperationCallback<PromiseLike<unknown>, Output<BaseShape>>,
            options?: Message | RefineOptions,
        ): this;
        replace<InputValue extends Any, OutputValue extends Any>(
            inputValue: InputValue,
            outputValue: OutputValue,
        ): ReplaceShape<
            NotShape<BaseShape, ExcludedShape>,
            InputValue,
            OutputValue,
        >;
        to<OutputShape extends AnyShape>(
            shape: OutputShape,
        ): PipeShape<NotShape<BaseShape, ExcludedShape>, OutputShape>;
        try(input: unknown, options?: ParseOptions): Err | Ok<Output<BaseShape>>;
        tryAsync(
            input: unknown,
            options?: ParseOptions,
        ): Promise<Err | Ok<Output<BaseShape>>>;
    }

    Type Parameters

    • BaseShape extends AnyShape

      The base shape.

    • ExcludedShape extends AnyShape

      The shape to which the output must not conform.

    Hierarchy (View Summary)

    Index

    Properties

    annotations: Dict = {}

    The dictionary of shape annotations.

    baseShape: BaseShape

    The base shape.

    excludedShape: ExcludedShape

    The shape to which the output must not conform.

    inputs: readonly unknown[]

    The array of unique input types and values that are accepted by the shape.

    isAsync: boolean

    true if the shape allows only Shape.parseAsync and throws an error if Shape.parse is called, or false if the shape can be used in both sync and async contexts.

    operations: readonly Operation[] = []

    The array of operations that are applied to the shape output.

    Methods

    • Synchronously parses the input.

      Parameters

      • input: unknown

        The shape input to parse.

      • options: ParseOptions

        Parsing options.

      • _nonce: number

        The globally unique number that identifies the parsing process.

      Returns Result<Output<BaseShape>>

      null if input matches the output, Ok that wraps the output, or an array of captured issues.

    • Returns input types and literal values that this shape can accept as an input.

      Returns readonly unknown[]

    • Must return true if the shape must be used in async context only, otherwise the shape can be used in both sync and async contexts. Override this method to implement a custom shape.

      Returns boolean

    • Returns true if the shape accepts given input type or value, or false otherwise.

      Parameters

      • input: unknown

        The type or value that must be checked.

      Returns boolean

    • Adds annotations to the shape.

      Parameters

      • annotations: ReadonlyDict

        Annotations to add.

      Returns this

      The clone of the shape with the updated annotations.

    • Returns a sub-shape that describes a value associated with the given property name, or null if there's no such sub-shape.

      Parameters

      • _key: unknown

        The key for which the sub-shape must be retrieved.

      Returns null | AnyShape

      The sub-shape or null if there's no such key in the shape.

    • Converts the shape and its child shapes to deep partial alternatives.

      Note: This method returns a shape without any operations.

      Returns NotShape

      The deep partial clone of the shape.

    • Synchronously parses the value.

      Parameters

      • input: unknown

        The value to parse.

      • Optionaloptions: ParseOptions

        Parsing options.

      Returns Output

      The value that conforms the output type of the shape.

      Error if the shape doesn't support the sync parsing, see Shape.isAsync.

      ValidationError if any issues occur during parsing.

    • Asynchronously parses the value.

      Parameters

      • input: unknown

        The value to parse.

      • Optionaloptions: ParseOptions

        Parsing options.

      Returns Promisify<Output<BaseShape>>

      The promise that resolves with the value that conforms the output type of the shape, or rejects with a ValidationError if any issues occur during parsing.

    • Asynchronously parses the value and returns undefined value if parsing fails.

      Parameters

      • input: unknown

        The value to parse.

      Returns Promisify<undefined | Output<BaseShape>>

      The value that conforms the output type of the shape.

    • Asynchronously parses the value and returns the default value if parsing fails.

      Type Parameters

      • DefaultValue

        The default value that is returned if parsing fails.

      Parameters

      • input: unknown

        The value to parse.

      • defaultValue: DefaultValue

        The default value that is returned if parsing fails.

      • Optionaloptions: ParseOptions

        Parsing options.

      Returns Promisify<Output<BaseShape> | DefaultValue>

      The value that conforms the output type of the shape.