I ended up using an ajax call inside the javascript validation file where I can access the value to be validated as follows:
$.validator.addMethod("custom-validation-name", function (value, element, params) {
var valid = false;
$.ajax({
url: "/Controller/Action",
type: "Get",
async:false,
data: { value-to-validate: value },
success: function (data) {
valid = parseInt(data) > 0;
}
});
return valid;
});
Create an action in the controller to check weather the value is valid or not
make sure that the async option is set to false