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

Add optional() helper #6

Closed
andywer opened this issue Jun 19, 2019 · 2 comments
Closed

Add optional() helper #6

andywer opened this issue Jun 19, 2019 · 2 comments

Comments

@andywer
Copy link

andywer commented Jun 19, 2019

Currently, our object description looks something like this:

  dateOfBirth: parseDate(),
  addressLine1: string(),
  addressLine2: {
    validator: string(),
    optional: true
  }

I think it would be really nice to have fefe come with a convenience function, so that we write it like this instead:

  dateOfBirth: parseDate(),
  addressLine1: string(),
  addressLine2: optional(string())

Of course it would be trivial for the user to write such a function themself, but it feels so basic, that it would probably make more sense to ship it as part of fefe.

Cheers!

@andrenarchy
Copy link
Member

This makes a lot of sense and I was already using this helper in other projects and I found myself copying it so this is the obvious solution. The same actually goes for a default() helper – however that is a keyword in js, any ideas?

@andrenarchy
Copy link
Member

Added in 1.1.0. The default() helper is discussed in #7.

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

2 participants