Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aspnet-validation

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aspnet-validation - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

.npmignore

1

dist/aspnet-validation.js

@@ -582,2 +582,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

input.classList.remove('input-validation-error');
input.classList.remove('input-validation-valid');
var spans = _this.messageFor[input.name];

@@ -584,0 +585,0 @@ if (spans) {

2

dist/aspnet-validation.min.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.aspnetValidation=t():e.aspnetValidation=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var a=r[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r.d(t,"MvcValidationProviders",function(){return i}),r.d(t,"ValidationService",function(){return o});var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(a,i){function o(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?a(e.value):new r(function(t){t(e.value)}).then(o,s)}u((n=n.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){function r(e){return function(t){return n([e,t])}}function n(r){if(a)throw new TypeError("Generator is already executing.");for(;u;)try{if(a=1,i&&(o=i[2&r[0]?"return":r[0]?"throw":"next"])&&!(o=o.call(i,r[1])).done)return o;switch(i=0,o&&(r=[0,o.value]),r[0]){case 0:case 1:o=r;break;case 4:return u.label++,{value:r[1],done:!1};case 5:u.label++,i=r[1],r=[0];continue;case 7:r=u.ops.pop(),u.trys.pop();continue;default:if(o=u.trys,!(o=o.length>0&&o[o.length-1])&&(6===r[0]||2===r[0])){u=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]<o[3])){u.label=r[1];break}if(6===r[0]&&u.label<o[1]){u.label=o[1],o=r;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(r);break}o[2]&&u.ops.pop(),u.trys.pop();continue}r=t.call(e,u)}catch(e){r=[6,e],i=0}finally{a=o=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}var a,i,o,s,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s},i=function(){function e(){this.required=function(e,t,r){return Boolean(e)},this.stringLength=function(e,t,r){if(!e)return!0;if(r.min){var n=parseInt(r.min);if(e.length<n)return!1}if(r.max){var a=parseInt(r.max);if(e.length>a)return!1}return!0},this.compare=function(e,t,r){if(!r.other)return!0;var n=document.getElementById(r.other.substr(2));return!n||n.value===e},this.range=function(e,t,r){if(!e)return!0;var n=parseFloat(e);if(isNaN(n))return!1;if(r.min){if(n<parseFloat(r.min))return!1}if(r.max){if(n>parseFloat(r.max))return!1}return!0},this.regex=function(e,t,r){return!e||!r.pattern||new RegExp(r.pattern).test(e)},this.email=function(e,t,r){return!e||/^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*(\.\w{2,})+$/.test(e)},this.creditcard=function(e,t,r){if(!e)return!0;if(/[^0-9 \-]+/.test(e))return!1;var n,a,i=0,o=0,s=!1;if(e=e.replace(/\D/g,""),e.length<13||e.length>19)return!1;for(n=e.length-1;n>=0;n--)a=e.charAt(n),o=parseInt(a,10),s&&(o*=2)>9&&(o-=9),i+=o,s=!s;return i%10==0},this.url=function(e,t,r){return!e||new RegExp("^(?:(?:https?|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))\\.?)(?::\\d{2,5})?(?:[/?#]\\S*)?$","i").test(e)},this.phone=function(e,t,r){return!e||!/[\+\-\s][\-\s]/g.test(e)&&/^\+?[0-9\-\s]+$/.test(e)},this.remote=function(e,t,r){return!e||new Promise(function(n,a){for(var i=r.url+"?"+t.name+"="+encodeURIComponent(e),o=r.additionalfields.split(","),s=0;s<o.length;s++){var u=o[s].substr(2);if(u!==t.name){var d=document.getElementById(u);d&&d.value&&(i=i+"&"+d.name+"="+encodeURIComponent(d.value))}}var f=new XMLHttpRequest;f.open("get",i),f.onload=function(e){if(f.status>=200&&f.status<300){var t=JSON.parse(f.responseText);n(t)}else a({status:f.status,statusText:f.statusText,data:f.responseText})},f.onerror=function(e){a({status:f.status,statusText:f.statusText,data:f.responseText})},f.send()})}}return e}(),o=function(){function e(){this.providers={},this.messageFor={},this.elementUIDs=[],this.elementByUID={},this.formInputs={},this.validators={},this.elementEvents={},this.summary={},this.debounce=300}return e.prototype.addProvider=function(e,t){this.providers[e]||(this.providers[e]=t)},e.prototype.addMvcProviders=function(){var e=new i;this.addProvider("required",e.required),this.addProvider("length",e.stringLength),this.addProvider("maxlength",e.stringLength),this.addProvider("minlength",e.stringLength),this.addProvider("equalto",e.compare),this.addProvider("range",e.range),this.addProvider("regex",e.regex),this.addProvider("creditcard",e.creditcard),this.addProvider("email",e.email),this.addProvider("url",e.url),this.addProvider("phone",e.phone),this.addProvider("remote",e.remote)},e.prototype.scanMessages=function(){for(var e=document.querySelectorAll("[data-valmsg-for]"),t=0;t<e.length;t++){var r=e[t],n=r.getAttribute("data-valmsg-for");this.messageFor[n]||(this.messageFor[n]=[]),this.messageFor[n].push(r)}},e.prototype.parseDirectives=function(e){for(var t={},r={},n="data-val-".length,a=0;a<e.length;a++){var i=e[a];if(0===i.name.indexOf("data-val-")){var o=i.name.substr(n);r[o]=i.value}}for(var o in r)!function(e){if(-1===e.indexOf("-")){for(var n=Object.keys(r).filter(function(t){return t!==e&&0===t.indexOf(e)}),a={error:r[e],params:{}},i=(e+"-").length,o=0;o<n.length;o++){var s=r[n[o]],u=n[o].substr(i);a.params[u]=s}t[e]=a}}(o);return t},e.prototype.guid4=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)})},e.prototype.getElementUID=function(e){var t=this.elementUIDs.filter(function(t){return t.node===e})[0];if(t)return t.uid;var r=this.guid4();return this.elementUIDs.push({node:e,uid:r}),this.elementByUID[r]=e,r},e.prototype.getFormValidationTask=function(e){var t=this.formInputs[e];if(!t||0===t.length)return null;for(var r=[],n=0;n<t.length;n++){var a=t[n];r.push(this.validators[a])}var i=r.map(function(e){return e()});return Promise.all(i).then(function(e){return e.every(function(e){return e})})},e.prototype.trackFormInput=function(e,t){var r=this,n=this.getElementUID(e);if(this.formInputs[n]||(this.formInputs[n]=[]),-1===this.formInputs[n].indexOf(t)&&this.formInputs[n].push(t),!this.elementEvents[n]){var a=function(t){var a=r.getFormValidationTask(n);a&&(t.preventDefault(),a.then(function(t){t&&e.submit()}).catch(function(e){console.log(e)}))};e.addEventListener("submit",a),e.addEventListener("reset",function(e){for(var t=r.formInputs[n],a=0,i=t;a<i.length;a++){var o=i[a],s=r.elementByUID[o];s.classList.remove("input-validation-error");var u=r.messageFor[s.name];if(u)for(var d=0;d<u.length;d++)u[d].innerHTML="";delete r.summary[o]}r.renderSummary()}),this.elementEvents[n]=a}},e.prototype.addInput=function(e){var t=this,r=this.getElementUID(e),n=this.parseDirectives(e.attributes),a=this.createValidator(e,n);if(this.validators[r]=a,this.trackFormInput(e.form,r),!this.elementEvents[r]){var i,o=function(e){var n=t.validators[r];clearTimeout(i),i=setTimeout(n,t.debounce)};"select"===e.tagName.toLowerCase()?e.addEventListener("change",o):e.addEventListener("input",o),this.elementEvents[r]=o}},e.prototype.scanInputs=function(){for(var e=document.querySelectorAll('[data-val="true"]'),t=0;t<e.length;t++){var r=e[t];this.addInput(r)}},e.prototype.createSummaryDOM=function(){if(!Object.keys(this.summary).length)return null;var e=document.createElement("ul");for(var t in this.summary){var r=document.createElement("li");r.innerHTML=this.summary[t],e.appendChild(r)}return e},e.prototype.renderSummary=function(){var e=document.querySelectorAll('[data-valmsg-summary="true"]');if(e.length){var t=JSON.stringify(this.summary,Object.keys(this.summary).sort());if(t!==this.renderedSummaryJSON){this.renderedSummaryJSON=t;for(var r=this.createSummaryDOM(),n=0;n<e.length;n++){var a=e[n];a.innerHTML="",r?(a.className="validation-summary-error",a.appendChild(r.cloneNode(!0))):a.className="validation-summary-valid"}}}},e.prototype.addError=function(e,t){var r=this.messageFor[e.name];if(r)for(var n=0;n<r.length;n++)r[n].innerHTML=t,r[n].className="field-validation-error";e.classList.remove("input-validation-valid"),e.classList.add("input-validation-error");var a=this.getElementUID(e);this.summary[a]=t,this.renderSummary()},e.prototype.removeError=function(e){var t=this.messageFor[e.name];if(t)for(var r=0;r<t.length;r++)t[r].innerHTML="",t[r].className="field-validation-valid";e.classList.remove("input-validation-error"),e.classList.add("input-validation-valid");var n=this.getElementUID(e);delete this.summary[n],this.renderSummary()},e.prototype.createValidator=function(e,t){var r=this;return function(){return n(r,void 0,void 0,function(){var r,n,i,o,s,u,d,f,l,c;return a(this,function(a){switch(a.label){case 0:r=[];for(n in t)r.push(n);i=0,a.label=1;case 1:return i<r.length?(o=r[i],s=t[o],(u=this.providers[o])?(d=u(e.value,e,s.params),f=!1,l=s.error,"boolean"!=typeof d?[3,2]:(f=d,[3,5])):(console.log("aspnet-validation provider not implemented: "+o),[3,6])):[3,7];case 2:return"string"!=typeof d?[3,3]:(f=!1,l=d,[3,5]);case 3:return[4,d];case 4:c=a.sent(),"boolean"==typeof c?f=c:(f=!1,l=c),a.label=5;case 5:if(!f)return this.addError(e,l),[2,!1];a.label=6;case 6:return i++,[3,1];case 7:return this.removeError(e),[2,!0]}})})}},e.prototype.bootstrap=function(){var e=this;this.addMvcProviders(),document.addEventListener("DOMContentLoaded",function(t){e.scanMessages(),e.scanInputs()})},e}()}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.aspnetValidation=t():e.aspnetValidation=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var a=r[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r.d(t,"MvcValidationProviders",function(){return i}),r.d(t,"ValidationService",function(){return o});var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(a,i){function o(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?a(e.value):new r(function(t){t(e.value)}).then(o,s)}u((n=n.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){function r(r){return function(o){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,a&&(i=a[2&r[0]?"return":r[0]?"throw":"next"])&&!(i=i.call(a,r[1])).done)return i;switch(a=0,i&&(r=[0,i.value]),r[0]){case 0:case 1:i=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,a=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(i=s.trys,!(i=i.length>0&&i[i.length-1])&&(6===r[0]||2===r[0])){s=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){s.label=r[1];break}if(6===r[0]&&s.label<i[1]){s.label=i[1],i=r;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(r);break}i[2]&&s.ops.pop(),s.trys.pop();continue}r=t.call(e,s)}catch(e){r=[6,e],a=0}finally{n=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,o])}}var n,a,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o},i=function(){return function(){this.required=function(e,t,r){return Boolean(e)},this.stringLength=function(e,t,r){if(!e)return!0;if(r.min){var n=parseInt(r.min);if(e.length<n)return!1}if(r.max){var a=parseInt(r.max);if(e.length>a)return!1}return!0},this.compare=function(e,t,r){if(!r.other)return!0;var n=document.getElementById(r.other.substr(2));return!n||n.value===e},this.range=function(e,t,r){if(!e)return!0;var n=parseFloat(e);return!isNaN(n)&&(!(r.min&&n<parseFloat(r.min))&&!(r.max&&n>parseFloat(r.max)))},this.regex=function(e,t,r){return!e||!r.pattern||new RegExp(r.pattern).test(e)},this.email=function(e,t,r){return!e||/^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*(\.\w{2,})+$/.test(e)},this.creditcard=function(e,t,r){if(!e)return!0;if(/[^0-9 \-]+/.test(e))return!1;var n,a,i=0,o=0,s=!1;if((e=e.replace(/\D/g,"")).length<13||e.length>19)return!1;for(n=e.length-1;n>=0;n--)a=e.charAt(n),o=parseInt(a,10),s&&(o*=2)>9&&(o-=9),i+=o,s=!s;return i%10==0},this.url=function(e,t,r){return!e||new RegExp("^(?:(?:https?|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))\\.?)(?::\\d{2,5})?(?:[/?#]\\S*)?$","i").test(e)},this.phone=function(e,t,r){return!e||!/[\+\-\s][\-\s]/g.test(e)&&/^\+?[0-9\-\s]+$/.test(e)},this.remote=function(e,t,r){return!e||new Promise(function(n,a){for(var i=r.url+"?"+t.name+"="+encodeURIComponent(e),o=r.additionalfields.split(","),s=0;s<o.length;s++){var u=o[s].substr(2);if(u!==t.name){var d=document.getElementById(u);d&&d.value&&(i=i+"&"+d.name+"="+encodeURIComponent(d.value))}}var f=new XMLHttpRequest;f.open("get",i),f.onload=function(e){if(f.status>=200&&f.status<300){var t=JSON.parse(f.responseText);n(t)}else a({status:f.status,statusText:f.statusText,data:f.responseText})},f.onerror=function(e){a({status:f.status,statusText:f.statusText,data:f.responseText})},f.send()})}}}(),o=function(){function e(){this.providers={},this.messageFor={},this.elementUIDs=[],this.elementByUID={},this.formInputs={},this.validators={},this.elementEvents={},this.summary={},this.debounce=300}return e.prototype.addProvider=function(e,t){this.providers[e]||(this.providers[e]=t)},e.prototype.addMvcProviders=function(){var e=new i;this.addProvider("required",e.required),this.addProvider("length",e.stringLength),this.addProvider("maxlength",e.stringLength),this.addProvider("minlength",e.stringLength),this.addProvider("equalto",e.compare),this.addProvider("range",e.range),this.addProvider("regex",e.regex),this.addProvider("creditcard",e.creditcard),this.addProvider("email",e.email),this.addProvider("url",e.url),this.addProvider("phone",e.phone),this.addProvider("remote",e.remote)},e.prototype.scanMessages=function(){for(var e=document.querySelectorAll("[data-valmsg-for]"),t=0;t<e.length;t++){var r=e[t],n=r.getAttribute("data-valmsg-for");this.messageFor[n]||(this.messageFor[n]=[]),this.messageFor[n].push(r)}},e.prototype.parseDirectives=function(e){for(var t={},r={},n="data-val-".length,a=0;a<e.length;a++){var i=e[a];if(0===i.name.indexOf("data-val-")){s=i.name.substr(n);r[s]=i.value}}var o=function(e){if(-1===e.indexOf("-")){for(var n=Object.keys(r).filter(function(t){return t!==e&&0===t.indexOf(e)}),a={error:r[e],params:{}},i=(e+"-").length,o=0;o<n.length;o++){var s=r[n[o]],u=n[o].substr(i);a.params[u]=s}t[e]=a}};for(var s in r)o(s);return t},e.prototype.guid4=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)})},e.prototype.getElementUID=function(e){var t=this.elementUIDs.filter(function(t){return t.node===e})[0];if(t)return t.uid;var r=this.guid4();return this.elementUIDs.push({node:e,uid:r}),this.elementByUID[r]=e,r},e.prototype.getFormValidationTask=function(e){var t=this.formInputs[e];if(!t||0===t.length)return null;for(var r=[],n=0;n<t.length;n++){var a=t[n];r.push(this.validators[a])}var i=r.map(function(e){return e()});return Promise.all(i).then(function(e){return e.every(function(e){return e})})},e.prototype.trackFormInput=function(e,t){var r=this,n=this.getElementUID(e);this.formInputs[n]||(this.formInputs[n]=[]);if(-1===this.formInputs[n].indexOf(t)&&this.formInputs[n].push(t),!this.elementEvents[n]){var a=function(t){var a=r.getFormValidationTask(n);a&&(t.preventDefault(),a.then(function(t){t&&e.submit()}).catch(function(e){console.log(e)}))};e.addEventListener("submit",a),e.addEventListener("reset",function(e){for(var t=0,a=r.formInputs[n];t<a.length;t++){var i=a[t],o=r.elementByUID[i];o.classList.remove("input-validation-error"),o.classList.remove("input-validation-valid");var s=r.messageFor[o.name];if(s)for(var u=0;u<s.length;u++)s[u].innerHTML="";delete r.summary[i]}r.renderSummary()}),this.elementEvents[n]=a}},e.prototype.addInput=function(e){var t=this,r=this.getElementUID(e),n=this.parseDirectives(e.attributes),a=this.createValidator(e,n);if(this.validators[r]=a,this.trackFormInput(e.form,r),!this.elementEvents[r]){var i,o=function(e){var n=t.validators[r];clearTimeout(i),i=setTimeout(n,t.debounce)};"select"===e.tagName.toLowerCase()?e.addEventListener("change",o):e.addEventListener("input",o),this.elementEvents[r]=o}},e.prototype.scanInputs=function(){for(var e=document.querySelectorAll('[data-val="true"]'),t=0;t<e.length;t++){var r=e[t];this.addInput(r)}},e.prototype.createSummaryDOM=function(){if(!Object.keys(this.summary).length)return null;var e=document.createElement("ul");for(var t in this.summary){var r=document.createElement("li");r.innerHTML=this.summary[t],e.appendChild(r)}return e},e.prototype.renderSummary=function(){var e=document.querySelectorAll('[data-valmsg-summary="true"]');if(e.length){var t=JSON.stringify(this.summary,Object.keys(this.summary).sort());if(t!==this.renderedSummaryJSON){this.renderedSummaryJSON=t;for(var r=this.createSummaryDOM(),n=0;n<e.length;n++){var a=e[n];a.innerHTML="",r?(a.className="validation-summary-error",a.appendChild(r.cloneNode(!0))):a.className="validation-summary-valid"}}}},e.prototype.addError=function(e,t){var r=this.messageFor[e.name];if(r)for(var n=0;n<r.length;n++)r[n].innerHTML=t,r[n].className="field-validation-error";e.classList.remove("input-validation-valid"),e.classList.add("input-validation-error");var a=this.getElementUID(e);this.summary[a]=t,this.renderSummary()},e.prototype.removeError=function(e){var t=this.messageFor[e.name];if(t)for(var r=0;r<t.length;r++)t[r].innerHTML="",t[r].className="field-validation-valid";e.classList.remove("input-validation-error"),e.classList.add("input-validation-valid");var n=this.getElementUID(e);delete this.summary[n],this.renderSummary()},e.prototype.createValidator=function(e,t){var r=this;return function(){return n(r,void 0,void 0,function(){var r,n,i,o,s,u,d,f,l,c;return a(this,function(a){switch(a.label){case 0:r=[];for(n in t)r.push(n);i=0,a.label=1;case 1:return i<r.length?(o=r[i],s=t[o],(u=this.providers[o])?(d=u(e.value,e,s.params),f=!1,l=s.error,"boolean"!=typeof d?[3,2]:(f=d,[3,5])):(console.log("aspnet-validation provider not implemented: "+o),[3,6])):[3,7];case 2:return"string"!=typeof d?[3,3]:(f=!1,l=d,[3,5]);case 3:return[4,d];case 4:"boolean"==typeof(c=a.sent())?f=c:(f=!1,l=c),a.label=5;case 5:if(!f)return this.addError(e,l),[2,!1];a.label=6;case 6:return i++,[3,1];case 7:return this.removeError(e),[2,!0]}})})}},e.prototype.bootstrap=function(){var e=this;this.addMvcProviders(),document.addEventListener("DOMContentLoaded",function(t){e.scanMessages(),e.scanInputs()})},e}()}])});
//# sourceMappingURL=aspnet-validation.min.js.map
{
"name": "aspnet-validation",
"version": "0.0.3",
"version": "0.0.4",
"description": "Enables ASP.NET Core MVC client-side validation, without JQuery!",

@@ -18,6 +18,8 @@ "main": "./dist/aspnet-validation.js",

"devDependencies": {
"ts-loader": "^3.0.3",
"typescript": "^2.5.3",
"ts-loader": "^3.1.1",
"typescript": "^2.6.1",
"uglifyjs-webpack-plugin": "^1.1.0",
"webpack": "^3.8.1"
}
},
"dependencies": {}
}

@@ -589,2 +589,3 @@ /**

input.classList.remove('input-validation-error');
input.classList.remove('input-validation-valid');

@@ -591,0 +592,0 @@ let spans = this.messageFor[input.name];

@@ -8,2 +8,3 @@ {

"skipLibCheck": true,
"strictFunctionTypes": true,

@@ -10,0 +11,0 @@ "noUnusedLocals": false,

const webpack = require('webpack');
const uglifyES = require('uglifyjs-webpack-plugin');

@@ -18,4 +19,7 @@ let tsconfigOverride = {

plugins: [
new webpack.optimize.UglifyJsPlugin({
sourceMap: true
new uglifyES({
sourceMap: true,
uglifyOptions: {
ecma: 5
}
})

@@ -22,0 +26,0 @@ ],

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc