arktype icon indicating copy to clipboard operation
arktype copied to clipboard

I18N error message customization

Open ssalbdivad opened this issue 1 year ago • 0 comments

Ideally any error message should be specifiable as a Record of strings representing locale IDs to the translations in that locale, e.g:

const creditCard = type("number", {mustBe: "a valid credit card"})

// could also be
const creditCard2 = type("number", {mustBe: {
  "en": "a valid credit card",
  "fr": "une carte de credit"
}})

Then, locale could be specified at a config like like:

atconfig({
  locale: "fr"
})

This feature would best be used with the global config option, which is planned here:

https://github.com/arktypeio/arktype/issues/691

ssalbdivad avatar Apr 19 '23 22:04 ssalbdivad