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

Better string predicates #7

Open
prayerslayer opened this issue Nov 24, 2016 · 2 comments
Open

Better string predicates #7

prayerslayer opened this issue Nov 24, 2016 · 2 comments

Comments

@prayerslayer
Copy link
Owner

There should be built-in predicates for

  • regexes
  • emails
  • URLs
  • ????
@michielvermeir
Copy link

I see you are already pulling in lodash.isregexp. What else is left except for exposing it in a regex predicate? Do you have any ideas on how to tackle predicates for the other two (i.e. emails and URLs)? Pull in another vetted library (such as validate.js) or would you rather roll your own?

@prayerslayer
Copy link
Owner Author

I think this only needs the regex predicate, something like (regex) => (data) => regex.test(data), and some tests (happy case, error cases, cases without regexes and strings).

Regarding emails and URLs I'm a bit torn. I don't want to bloat js.spec because of these helpers, but I want to include them so it's more useful right out of the box. On the other hand including those things and then doing a sloppy job is not great, so I'd explore how we can use validator.js without adding too much kilobytes.

Does that help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants