forked from thetutlage/angular-validation-schema
-
Notifications
You must be signed in to change notification settings - Fork 0
/
angular-validation-schema.min.js
1 lines (1 loc) · 1.36 KB
/
angular-validation-schema.min.js
1
(function(){angular.module("validation.schema",[]).provider("validationSchema",function(){var a={};this.set=function(b,c){a[b]=c},this.get=function(b){return a[b]},this.$get=function(){return{set:this.set,get:this.get}}}).directive("validationSchema",["validationSchema","$injector",function(a,b){return{restrict:"AE",compile:function(c,d){function i(a){var b=a+" Schema not found";console.warn("VALIDATION SCHEMA :",b)}function j(a){function b(a){return angular.forEach(arguments,function(c){c!==a&&angular.forEach(c,function(c,d){a[d]&&a[d].constructor&&a[d].constructor===Object?b(a[d],c):a[d]=a[d]||c})}),a}a.globals&&(f.validations=a.globals.validations||f.validations,f["validate-on"]=a.globals["validate-on"]||f["validate-on"],g=a.globals.messages||{},delete a.globals);var d=c[0].querySelectorAll("[name]");angular.forEach(d,function(c){var d=angular.element(c),e=d.attr("name");if(a[e]){var h=b(a[e],f);d.attr("validator",h.validations),d.attr("valid-method",h["validate-on"]),h.messages=h.messages||{},h.messages=b(h.messages,g),angular.forEach(h.messages,function(a,b){var c=a.error?a.error.replace("%field%",e):"",f=a.success?a.success.replace("%field%",e):"";d.attr(b+"-error-message",c),d.attr(b+"-success-message",f)})}})}var e=b.get("$validation"),f={validations:"required","validate-on":e.getValidMethod()||"watch"},g={},h=a.get(d.schema);h?j(h):i(d.schema)}}}])}).call(this);