Last active
June 12, 2016 11:15
-
-
Save andrei-cacio/d5af089a0241c11aa77885c5c67f95b6 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
import $ from 'jquery'; | |
export const isEmpty = value => !value.length; | |
export default function getValidator(rule, inputSelector, valueGetter) { | |
return { | |
validate() { | |
const $input = $(inputSelector); | |
const value = valueGetter(); | |
if (isEmpty(value)) { | |
$input.addClass('error'); | |
return false; | |
} | |
else { | |
$input.removeClass('error'); | |
return true; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment