Does rails have an API to check and see if times or dates exist?
Supposing a guy doesn't want users to include months or days or anything that remotely sounds like a time in his text area form. Could he use something besides regex to validate that? Is there a built-in API for that? I do use the Chronic gem somewhere else, but if I used it for this purpose, it would probably be out-of-the-box.
Here's an example .
I'm offering this wonderful sheep and it's only good until June.
Blam! Can't have this then because they said the word, 'June'. Can R开发者_JAVA技巧uby detect that?
This doesn't answer my question, but this is the regex alternative. I'm posting it in case anyoen else might need it.
/|\/|[Jj][Aa][Nn][Uu][Aa][Rr][Yy]|[Jj][Aa][Nn](\s|\.)|[Ff][Ee][Bb][Rr][Uu][Aa][Rr][Yy]|[Ff][Ee][Bb](\s|\.)|[Mm][Aa][Rr][Cc][Hh]|[Mm][Aa][Rr](\s|\.)|[Aa][Pp][Rr][Ii][Ll]|[Aa][Pp][Rr](\s|\.)|[Jj][Uu][Nn][Ee]|[Jj][Uu][Ll][Yy]|[Aa][Uu][Gg][Uu][Ss][Tt]|[Aa][Uu][Gg](\s|\.)|[Ss][Ee][Pp][Tt][Ee][Mm][Bb][Ee][Rr]|[Ss][Ee][Pp][Tt](\s|\.)|[Nn][Oo][Vv][Ee][Mm][Bb][Ee][Rr]|[Nn][Oo][Vv](\s|\.)|[Dd][Ee][Cc][Ee][Mm][Bb][Ee][Rr]|[Dd][Ee][Cc](\s|\.)|[Ss][Uu][Nn]\.|[Ss][Uu][Nn][Dd][Aa][Yy]|[Mm][Oo][Nn][Dd][Aa][Yy]|[Mm][Oo][Nn](\s|\.)|[Tt][Uu][Ee][Ss][Dd][Aa][Yy]|[Tt][Uu][Ee][Ss](\s|\.)|[Ww][Ee][Dd][Nn][Ee][Ss][Dd][Aa][Yy]|[Ww][Ee][Dd](\s|\.)|[Tt][Hh][Uu][Rr][Ss][Dd][Aa][Yy]|[Tt][Hh][Uu][Rr](\s|\.)|[Ff][Rr][Ii][Dd][Aa][Yy]|[Ff][Rr][Ii](\s|\.)|[Ss][Aa][Tt][Uu][Rr][Dd][Aa][Yy]|[Ss][Aa][Tt](\s|\.))/
I didn't include the word 'May or may', and Sun but it checks for Sun.
精彩评论