Created
July 4, 2017 17:09
-
-
Save bookercodes/c8bb35801b06920f08178d2fc55f31d1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isGreaterThan = a => b => b.length > a | |
const isWistiaLink = text => | |
/https:\/\/pusher-1.wistia.com\/medias\/\w{10}$/.test(text) | |
const isMeetupLink = text => | |
/https:\/\/www.meetup.com\/.+\/events\/\d+\/?$/.test(text) | |
const notEmpty = b => b !== '' | |
const isFullName = text => /[A-Za-z]+\s[A-Za-z]+$/g.test(text) | |
const validationRules = { | |
title: [[notEmpty, 'Whops 😳! You need to enter a title']], | |
wistiaUrl: [ | |
[notEmpty, 'Whops 😳! You need to enter a title'], | |
[ | |
isWistiaLink, | |
"Oh boy 😳! This isn't a valid Wistia link. Wistia links should look like https://pusher-1.wistia.com/medias/rbptq6k358" | |
] | |
], | |
meetupLink: [ | |
[ | |
isMeetupLink, | |
`Uh oh. That isn't a valid meetup link. Remember we need the link to a specific event like https://www.meetup.com/DeveloperSouthCoast/events/238643287/` | |
] | |
], | |
meetup: [[notEmpty, '']], | |
month: [[notEmpty, '']], | |
speakerName: [ | |
[isFullName, "Please make sure you enter the speaker's full name"] | |
], | |
speakerEmail: [[validator.isEmail, "This ain't a valid email yo"]] | |
} | |
const EnhancedSubmitForm = Revalidation(SubmitForm) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment