Skip to content

Custom key validation in records #75

@mary-ext

Description

@mary-ext

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)`),
  ),
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions