Beignet API reference
    Preparing search index...

    Function defineValueObject

    • Create a new value object builder.

      Value objects are schema-backed primitives for domain concepts such as email addresses or money values. Beignet does not add a runtime brand; the schema output controls the runtime value.

      Type Parameters

      • Name extends string

      Parameters

      Returns ValueObjectBuilder<Name, never>

      const Email = defineValueObject("Email")
      .schema(z.string().email())
      .build();

      type Email = typeof Email.Type;

      const email = await Email.create("test@example.com"); // OK
      const isValid = await Email.isValid("test@example.com"); // true