Skip to content

Custom error messages don't work on morph #1479

Closed

Description

@robin-blanchard

Report a bug

I am trying to have custom error messages on morphs. Here is an example for a Port type.

The error message is still the original one from Arktype.

🔎 Search Terms

morph, error, configure

🧩 Context

  • ArkType version: 2.1.20
  • TypeScript version (5.1+): 5.6.2

🧑‍💻 Repro

Playground Link: https://arktype.io/playground?code=import%20%7B%20type%20%7D%20from%20%22arktype%22%0A%0Aconst%20Thing%20%3D%20type(%22string.numeric.parse%20%7C%20number%22)%0A%09.to(%220%3Cnumber%3C%3D65535%22)%0A%09.configure(%7B%0A%09%09message%3A%20(ctx)%20%3D%3E%20%7B%0A%09%09%09return%20%22This%20is%20a%20custom%20error%22%0A%09%09%7D%0A%09%7D)%0A%0A%2F%2F%20const%20out%20%3D%20Thing(%22abcd%22)%20%2F%2F%20Shows%20custom%20error%0Aconst%20out%20%3D%20Thing(%22999999%22)%20%2F%2F%20Shows%20default%20error%0A%0A

import { type } from "arktype"

const Thing = type("string.numeric.parse | number")
    .to("0<number<=65535")
    .configure({
        message: (ctx) => {
            return "This is a custom error"
        }
    })

// const out = Thing("abcd") // Shows custom error
const out = Thing("999999") // Shows default error

Activity

  1. ssalbdivad commented on Nov 18, 2026

    @ssalbdivad
    Member

    Fixed in 3.0.0-beta.0 (#1728). Try it with npm i arktype@next.

  2. moved this from To do to Done (merged or closed) in arktypeioon Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

  • Status
    Done (merged or closed)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions