-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathangular-validation-schema.min.js
1 lines (1 loc) · 1.13 KB
/
angular-validation-schema.min.js
1
(function(){var e=angular.module("validation.schema",[]).provider("validationSchema",function(){var e={};this.set=function(t,n){e[t]=n};this.get=function(t){return e[t]};this.$get=function(){return{set:this.set,get:this.get}}}).directive("validationSchema",["validationSchema",function(e){return{restrict:"AE",compile:function(t,n){function s(e){var t=e+" Schema not found";console.warn("VALIDATION SCHEMA :",t)}function o(e){function n(e){angular.forEach(arguments,function(t){if(t!==e){angular.forEach(t,function(t,r){if(e[r]&&e[r].constructor&&e[r].constructor===Object){n(e[r],t)}else{e[r]=e[r]||t}})}});return e}var i=t[0].querySelectorAll("input,select,textarea");angular.forEach(i,function(t){var i=angular.element(t);var s=i.attr("name");if(e[s]){var o=n(e[s],r);i.attr("validator",o.validations);i.attr("valid-method",o["validate-on"]);angular.forEach(o.messages,function(e,t){i.attr(t+"-error-message",e.error||"");i.attr(t+"-success-message",e.success||"")})}})}var r={validations:"required",messages:{required:{error:"Required",success:"Good Required"}},"validate-on":"watch"};var i=e.get(n.schema);if(i){o(i)}else{s(n.schema)}}}}])}).call(this);