Closed waynevanson closed 3 years ago
This looks a lot like what fromRefinement is doing. You would use it like this
fromRefinement('MyRegExpType', (u): u is string => t.string.is(u) && /test/.test(u))
Or what I would recommend when you have strings that follow a certain structure is to use a branded type
@mlegenhausen That does look similar. I feel like the DX of the suggested solution for RegExp's are a better.
I didn't get that far in the documentation, so thank you for the references.
May we close this issue @waynevanson ?
🚀 Feature request
Current Behavior
Feature does not exist.
Desired Behavior
User to use a
RegExp
to assert astring
.Suggested Solution
First time I've written one of these. Not tested.
Who does this impact? Who is this for?
All users
Describe alternatives you've considered
No alternatives. Tried looking around but didn't see anything.
Additional context
Your environment