Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom key validation in records #75

Open
mary-ext opened this issue Dec 5, 2024 · 0 comments
Open

Custom key validation in records #75

mary-ext opened this issue Dec 5, 2024 · 0 comments

Comments

@mary-ext
Copy link

mary-ext commented Dec 5, 2024

This is easily implemented by chaining my own assertions on top, but I think it's still worth suggesting:

It would be nice if I could pass a custom key type to records, e.g. here in this case I want to limit the length of keys used in a record.

const document = v.object({
  services: v.record(
    v.object({
      type: v.string(),
      // ...
    }),
    v.string()
      .assert((input) => input.length <= 32, `service id too long (max 32)`),
  ),
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant