How to use `@sapphire/shapeshift ` dateValid & stringRegex

I have a slash command that needs to take in a date input in the format of YYYY-MM-DD. I want to perform validation on this and throw an error if it is not in this format or not a valid date. I was looking at the documenation, but I was hoping to see a code example to help explain the usage. I appreciate the explanation and help.
Solution:
You can't do it all in one validation I think so instead:
s.string.regex(/\d{4}-\d{2}-\d{2}/)
s.string.regex(/\d{4}-\d{2}-\d{2}/)
...
Jump to solution
1 Reply
Solution
Favna
Favna16mo ago
You can't do it all in one validation I think so instead:
s.string.regex(/\d{4}-\d{2}-\d{2}/)
s.string.regex(/\d{4}-\d{2}-\d{2}/)
Or just try and parse it with new Date() first and use s.date.valid.run(...)