Reference another schema type as default?

Hello, I'm relatively new to Arktype. I've managed to figure out most of our Zod migration, however I have a couple scenarios where I would like to reference other types as default values -or- compose a 'computed' property.

In this scenario I'd like to use the provided 'createdAt' value as the default 'modifiedAt' value:
import { type } from 'arktype';

const UserSchema = type({
  firstName: type("string"),
  lastName: type("string"),
  createdAt: type("string.date.iso.parse"),
  modifiedAt: type("string.date.iso.parse").default(// -> default to createdAt)
})


And in this scenario, I'm doing some parsing prior to return an API payload. I would like to compose a type based off two other types:
const UserSchema = type({
  firstName: type("string"),
  lastName: type("string"),
  name: type("string").default(// -> reference firstName and lastName),
})


Note : these are simplified examples

Both seem somewhat related, but I haven't figured out how or if it's possible to accomplish these.
Was this page helpful?