Skip to content

Keep Refinements? #373

Closed
Closed
@mikecann

Description

@mikecann

Hi,

Apologies if this doesn't follow the usual issue convention.

I noticed that refinements are now deprecated in favour of brands. Im just wondering the reason for this exactly as the new syntax for brands is considerably more verbose and is limited.

Previously I enjoyed writing nice terse validation such as:

const rxEmail = /^[^@\s]+@[^@\s]+\.[^@\s]+$/;

const Email = t.refinement(t.string, s => rxEmail.test(s), "Email");

const MaxLengthString = (len: number) =>
  t.refinement(t.string, s => s.length <= len, `MaxLengthString${len}`);

const EmailSubject = MaxLengthString(50);

export const GuestSenderDetails = t.strict({
  name: t.string,
  email: Email,
});

export const NewVideoMessageDetails = t.strict({
  subject: EmailSubject,
  sender: GuestSenderDetails,
});

Now with brands this would be considerably more verbose and im not even sure if MaxLengthString is even possible.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions