Skip to content

Instantly share code, notes, and snippets.

@einarwh
Last active December 13, 2015 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save einarwh/4955948 to your computer and use it in GitHub Desktop.
Save einarwh/4955948 to your computer and use it in GitHub Desktop.
Plumbing code to hook up Mkay to jQuery.Validate.
jQuery.validator.addMethod("mkay", function (value, element, param) {
"use strict";
var ruledata = JSON && JSON.parse(param) || $.parseJSON(param);
var validator = MKAY.getValidator(ruledata.rule, ruledata.ast);
return validator();
});
jQuery.validator.unobtrusive.adapters.add("mkay", ["rule"], function (options) {
"use strict";
options.rules.mkay = options.params.rule;
options.messages.mkay = options.message;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment