Skip to content

Instantly share code, notes, and snippets.

@andrei-cacio
Last active June 12, 2016 11:15
Show Gist options
  • Save andrei-cacio/d5af089a0241c11aa77885c5c67f95b6 to your computer and use it in GitHub Desktop.
Save andrei-cacio/d5af089a0241c11aa77885c5c67f95b6 to your computer and use it in GitHub Desktop.
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