arktypea
arktype6mo ago
GreggOD

empty string now but length string later?

For a few of my schemas i have them setup like this, which means the values can be empty string:

export const telephone = type({
  international: "string",
  "local?": "string",
  "readable?": "string"
})


But there are cases where I want to ensure the values are filled in, is there a way with arktype to specify that I want a schema to expect a value?
// i want this to throw an error because i expect the international field to be present
telephone.from({
  international: ""
})


This is something that I run into a lot where the initial values stored into the DB are empty strings but when the data is updated via some controller i need to ensure the values are passed in. I dont want to duplicate all my schemas. Any recommendations?
Was this page helpful?