Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

customs.js

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

customs.js - npm Package Compare versions

Comparing version
0.6.0
to
0.6.1
+82
-52
.idea/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="844c3fc2-c9bf-4da2-bd5e-364cb8e25684" name="Default" comment="" />
<list default="true" id="844c3fc2-c9bf-4da2-bd5e-364cb8e25684" name="Default" comment="">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/package.json" afterPath="$PROJECT_DIR$/package.json" />
</list>
<ignored path="customs.js.iws" />

@@ -36,7 +38,17 @@ <ignored path=".idea/workspace.xml" />

</file>
<file leaf-file-name="customs.js" pinned="false" current-in-tab="true">
<file leaf-file-name="package.json" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/package.json">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.42857143">
<caret line="24" column="4" selection-start-line="24" selection-start-column="4" selection-end-line="24" selection-end-column="4" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="customs.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/customs.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.3125">
<caret line="52" column="2" selection-start-line="52" selection-start-column="2" selection-end-line="52" selection-end-column="2" />
<state vertical-scroll-proportion="0.0">
<caret line="54" column="44" selection-start-line="54" selection-start-column="44" selection-end-line="54" selection-end-column="44" />
<folding />

@@ -47,2 +59,12 @@ </state>

</file>
<file leaf-file-name="customs.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/customs.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="206" column="0" selection-start-line="206" selection-start-column="0" selection-end-line="206" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>

@@ -64,6 +86,6 @@ </component>

<option value="$PROJECT_DIR$/src/checks.js" />
<option value="$PROJECT_DIR$/package.json" />
<option value="$PROJECT_DIR$/test/customs.js" />
<option value="$PROJECT_DIR$/src/exam.js" />
<option value="$PROJECT_DIR$/src/customs.js" />
<option value="$PROJECT_DIR$/test/customs.js" />
<option value="$PROJECT_DIR$/package.json" />
</list>

@@ -296,3 +318,3 @@ </option>

<component name="ProjectFrameBounds">
<option name="x" value="158" />
<option name="x" value="509" />
<option name="y" value="23" />

@@ -327,3 +349,3 @@ <option name="width" value="1068" />

<panes>
<pane id="Scratches" />
<pane id="Scope" />
<pane id="ProjectPane">

@@ -399,16 +421,2 @@ <subPane>

<PATH_ELEMENT>
<option name="myItemId" value="dist" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="customs.js" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="customs.js" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="build" />

@@ -420,3 +428,3 @@ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />

</pane>
<pane id="Scope" />
<pane id="Scratches" />
</panes>

@@ -617,7 +625,13 @@ </component>

</task>
<option name="localTasksCounter" value="12" />
<task id="LOCAL-00012" summary="Refactor appendCheck as a static method">
<created>1468357623289</created>
<option name="number" value="00012" />
<option name="project" value="LOCAL" />
<updated>1468357623290</updated>
</task>
<option name="localTasksCounter" value="13" />
<servers />
</component>
<component name="ToolWindowManager">
<frame x="158" y="23" width="1068" height="981" extended-state="0" />
<frame x="509" y="23" width="1068" height="981" extended-state="0" />
<editor active="true" />

@@ -632,7 +646,5 @@ <layout>

<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32772166" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.121484816" sideWeight="0.4979827" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.24928367" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />

@@ -642,5 +654,7 @@ <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />

<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.121484816" sideWeight="0.4979827" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32894737" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
</layout>

@@ -669,3 +683,4 @@ </component>

<MESSAGE value="Functionality to extend the runtime validation rules&#10;" />
<option name="LAST_COMMIT_MESSAGE" value="Functionality to extend the runtime validation rules&#10;" />
<MESSAGE value="Refactor appendCheck as a static method" />
<option name="LAST_COMMIT_MESSAGE" value="Refactor appendCheck as a static method" />
</component>

@@ -680,2 +695,20 @@ <component name="XDebuggerManager">

<state vertical-scroll-proportion="0.0">
<caret line="12" column="33" selection-start-line="12" selection-start-column="0" selection-end-line="12" selection-end-column="33" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/customs.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/exam.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="27" column="11" selection-start-line="27" selection-start-column="11" selection-end-line="27" selection-end-column="11" />

@@ -700,3 +733,2 @@ <folding>

<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>

@@ -853,14 +885,13 @@ </provider>

</entry>
<entry file="file://$PROJECT_DIR$/package.json">
<entry file="file://$PROJECT_DIR$/test/checks.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.28503564">
<caret line="16" column="32" selection-start-line="16" selection-start-column="32" selection-end-line="16" selection-end-column="32" />
<folding />
<state vertical-scroll-proportion="0.0">
<caret line="15" column="80" selection-start-line="15" selection-start-column="80" selection-end-line="15" selection-end-column="80" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/checks.js">
<entry file="file://$PROJECT_DIR$/test/exam.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="15" column="80" selection-start-line="15" selection-start-column="80" selection-end-line="15" selection-end-column="80" />
<state vertical-scroll-proportion="0.017321017">
<caret line="78" column="10" selection-start-line="78" selection-start-column="10" selection-end-line="78" selection-end-column="10" />
<folding />

@@ -870,14 +901,13 @@ </state>

</entry>
<entry file="file://$PROJECT_DIR$/test/customs.js">
<entry file="file://$PROJECT_DIR$/src/utils.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="3.4468822">
<caret line="201" column="0" selection-start-line="201" selection-start-column="0" selection-end-line="201" selection-end-column="0" />
<folding />
<state vertical-scroll-proportion="0.15588914">
<caret line="11" column="35" selection-start-line="11" selection-start-column="23" selection-end-line="11" selection-end-column="35" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/exam.js">
<entry file="file://$PROJECT_DIR$/src/checks.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.017321017">
<caret line="78" column="10" selection-start-line="78" selection-start-column="10" selection-end-line="78" selection-end-column="10" />
<state vertical-scroll-proportion="1.2644342">
<caret line="75" column="33" selection-start-line="75" selection-start-column="33" selection-end-line="75" selection-end-column="33" />
<folding />

@@ -897,6 +927,6 @@ </state>

</entry>
<entry file="file://$PROJECT_DIR$/src/utils.js">
<entry file="file://$PROJECT_DIR$/src/customs.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.15588914">
<caret line="11" column="35" selection-start-line="11" selection-start-column="23" selection-end-line="11" selection-end-column="35" />
<state vertical-scroll-proportion="0.0">
<caret line="54" column="44" selection-start-line="54" selection-start-column="44" selection-end-line="54" selection-end-column="44" />
<folding />

@@ -906,6 +936,6 @@ </state>

</entry>
<entry file="file://$PROJECT_DIR$/src/checks.js">
<entry file="file://$PROJECT_DIR$/test/customs.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="1.2644342">
<caret line="75" column="33" selection-start-line="75" selection-start-column="33" selection-end-line="75" selection-end-column="33" />
<state vertical-scroll-proportion="0.0">
<caret line="206" column="0" selection-start-line="206" selection-start-column="0" selection-end-line="206" selection-end-column="0" />
<folding />

@@ -915,6 +945,6 @@ </state>

</entry>
<entry file="file://$PROJECT_DIR$/src/customs.js">
<entry file="file://$PROJECT_DIR$/package.json">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.3125">
<caret line="52" column="2" selection-start-line="52" selection-start-column="2" selection-end-line="52" selection-end-column="2" />
<state vertical-scroll-proportion="0.42857143">
<caret line="24" column="4" selection-start-line="24" selection-start-column="4" selection-end-line="24" selection-end-column="4" />
<folding />

@@ -921,0 +951,0 @@ </state>

@@ -43,3 +43,3 @@ /*!

/**
* @public
* @static
* @memberof Customs

@@ -49,6 +49,12 @@ *

*
* @example
* Customs.appendCheck('truth', {
* 'msg': 'The {0} field must be truthy.',
* 'check': function(val) { return !!val; }
* });
*
* @param {string} name - name of the new check
* @param {object} opts - custom check logic
*/
Customs.prototype.appendCheck = function (name, opts) {
Customs.appendCheck = function (name, opts) {
checks[name] = opts;

@@ -55,0 +61,0 @@ };

@@ -43,3 +43,3 @@ /*!

/**
* @public
* @static
* @memberof Customs

@@ -49,6 +49,12 @@ *

*
* @example
* Customs.appendCheck('truth', {
* 'msg': 'The {0} field must be truthy.',
* 'check': function(val) { return !!val; }
* });
*
* @param {string} name - name of the new check
* @param {object} opts - custom check logic
*/
Customs.prototype.appendCheck = function (name, opts) {
Customs.appendCheck = function (name, opts) {
checks[name] = opts;

@@ -55,0 +61,0 @@ };

@@ -585,3 +585,3 @@ (function (root, factory) {

/**
* @public
* @static
* @memberof Customs

@@ -591,6 +591,12 @@ *

*
* @example
* Customs.appendCheck('truth', {
* 'msg': 'The {0} field must be truthy.',
* 'check': function(val) { return !!val; }
* });
*
* @param {string} name - name of the new check
* @param {object} opts - custom check logic
*/
Customs.prototype.appendCheck = function (name, opts) {
Customs.appendCheck = function (name, opts) {
checks[name] = opts;

@@ -597,0 +603,0 @@ };

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

!function(a,b){"function"==typeof define&&define.amd?define([],function(){return a.returnExportsGlobal=b()}):"object"==typeof exports?module.exports=b():a.Customs=b()}(this,function(){var a,b,c,d,e,f,g,h;return a=function(a){return"[object Array]"===Object.prototype.toString.call(a)},b=function(a){return function(b){if(a(b))return 0===b.length;for(var c in b)if(b.hasOwnProperty(c))return!1;return!0}}(a),c=function(a,b){return a.replace(/{([^{}]*)}/g,function(a,c){return"string"==typeof b[c]?b[c]:a})},d=function(a){for(var b=1;b<arguments.length;b++)for(var c in arguments[b])a[c]=arguments[b][c];return a},e=function(a){var e=b,f=c,g=d;return{isEmpty:e,tmpl:f,extend:g,createListParser:function(a){var b=this;return function(){return b.listParser.apply(a,arguments)}},listParser:function(a){for(var b=a.split(","),c=0;c<b.length;c++){var d=String(b[c]).replace(/^\s+|\s+$/g,"");if(!this.regex.test(d))return!1}return!0}}}({}),g=function(a){var b=e,c={numeric:/^[0-9]+$/,integer:/^\-?[0-9]+$/,decimal:/^\-?[0-9]*\.?[0-9]+$/,email:/^[a-zA-Z0-9.!#$%&amp;'*+\-\/=?\^_`{|}~\-]+@[a-zA-Z0-9\-]+(?:\.[a-zA-Z0-9\-]+)*$/,alpha:/^[a-z]+$/i,alphaNumeric:/^[a-z0-9]+$/i,alphaDash:/^[a-z0-9_\-]+$/i,natural:/^[0-9]+$/i,naturalNoZero:/^[1-9][0-9]*$/i,ip:/^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})$/i,base64:/[^a-zA-Z0-9\/\+=]/i,numericDash:/^[\d\-\s]+$/,url:/^(https?|s?ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i},d={};d.required={msg:"The {0} field is required.",check:function(a){return null!==a&&"object"==typeof a?!b.isEmpty(a):null!==a&&""!==a}},d["default"]={msg:"The {0} field is still set to default, please change.",check:function(a,b){return a!==b}},d.and={msg:"The {0} field needs to validate all fields in the {1} group.",check:function(){return!0}},d.email={msg:"The {0} field must contain a valid email address.",check:function(a){return c.email.test(a)}},d.minLength={msg:"The {0} field must be at least {1} characters in length.",check:function(a,b){return c.numeric.test(b)?a.length>=parseInt(b,10):!1}},d.maxLength={msg:"The {0} field must not exceed {1} characters in length.",check:function(a,b){return c.numeric.test(b)?a.length<=parseInt(b,10):!1}},d.exactLength={msg:"The {0} field must be exactly {1} characters in length.",check:function(a,b){return c.numeric.test(b)?a.length===parseInt(b,10):!1}},d.greaterThan={msg:"The {0} field must contain a number greater than {1}.",check:function(a,b){return c.decimal.test(a)?parseFloat(a)>parseFloat(b):!1}},d.lessThan={msg:"The {0} field must contain a number less than {1}.",check:function(a,b){return c.decimal.test(a)?parseFloat(a)<parseFloat(b):!1}},d.alpha={msg:"The {0} field must only contain alphabetical characters.",check:function(a){return c.alpha.test(a)}},d.alphaNumeric={msg:"The {0} field must only contain alpha-numeric characters.",check:function(a){return c.alphaNumeric.test(a)}},d.alphaDash={msg:"The {0} field must only contain alpha-numeric characters, underscores, and dashes.",check:function(a){return c.alphaDash.test(a)}},d.numeric={msg:"The {0} field must contain only numbers.",check:function(a){return c.numeric.test(a)}},d.numericDash={msg:"The {0} field must only contain alpha-numeric characters, underscores, and dashes.",check:function(a){return c.numericDash.test(a)}},d.integer={msg:"The {0} field must contain an integer.",check:function(a){return c.integer.test(a)}},d.decimal={msg:"The {0} field must contain a decimal number.",check:function(a){return c.decimal.test(a)}},d.natural={msg:"The {0} field must contain only positive numbers.",check:function(a){return c.natural.test(a)}},d.naturalNoZero={msg:"The {0} field must contain a number greater than zero.",check:function(a){return c.naturalNoZero.test(a)}},d.url={msg:"The {0} field must contain a valid URL.",check:function(a){return c.url.test(a)}},d.creditCard={msg:"The {0} field must contain a valid credit card number.",check:function(a){if(!c.numericDash.test(a))return!1;for(var b=a.replace(/[ -]+/g,""),d=b.length,e=0,f=0,g=[[0,1,2,3,4,5,6,7,8,9],[0,2,4,6,8,1,3,5,7,9]];d--;)f+=g[e][parseInt(b.charAt(d),10)],e^=1;return f%10===0&&f>0}},d.fileType={msg:"The {0} field must contain only {1} files.",check:function(a,b){for(var c=a.substr(a.lastIndexOf(".")+1),d=b.split(","),e=0;e<d.length;e++){var f=String(d[e]).replace(/^\s+|\s+$/g,"");if(c===f)return!0}return!1}},d.equalTo={msg:"The value of {0} does not match the value of {1}.",check:function(a,b,c){return a===c[b]}};for(var f in c){var g=(c[f],f+"s");d[g]={msg:"The {0} field must contain all valid "+g+".",regex:c[f]},d[g].check=b.createListParser(d[g])}return d}({}),h=function(a){var b=e,c=g,d=function(){this.isValid=!0,this.errors={},this.andGroup={},this.andCounter={}};return d.prototype.run=function(a,b){for(var c in a)b[c]&&this.checkRules(c,a[c],b[c],a);for(var d in this.andGroup)this.checkGroups(this.andGroup[d],this.andCounter[d])},d.prototype.checkGroups=function(a,c){if(c.empty===c.count)for(var d in a){var e=a[d];delete this.errors[e]}b.isEmpty(this.errors)&&(this.isValid=!0)},d.prototype.checkRules=function(a,b,c,d){var e=[],f=""===b,g=c[0];if(f&&g&&"required"!==c[0].name)return!0;var h="";for(var i in c){var j=c[i];"default"===j.name&&(h=j.args)}for(i in c){var k=this.checkRule(a,b,c[i],d,h);k&&e.push(k)}e.length&&(this.errors[a]=e)},d.prototype.checkRule=function(a,b,d,e,f){if(!c[d.name])throw new Error("There is no check defined by the name: "+d.name);if("and"===d.name){var g=d.args,h=d.name+"Group",i=this[h][g]||[];i.push(a),this[h][g]=i,h=d.name+"Counter";var j=this[h][g]||{empty:0,count:0};b===f&&j.empty++,j.count++,this[h][g]=j}return c[d.name].check(b,d.args,e)?null:this.formatError(a,d)},d.prototype.formatError=function(a,d){this.isValid=!1;var e=c[d.name].msg,f=[a];return d.args&&(f=f.concat([d.args])),{name:d.name,msg:b.tmpl(e,f)}},d}({}),f=function(a){var b=h,c=g,d=function(a){this.rules=this.build(a)};return d.prototype.appendCheck=function(a,b){c[a]=b},d.prototype.check=function(a){var c=new b;return c.run(a,this.rules||{}),{isValid:c.isValid,errors:c.errors}},d.prototype.build=function(a){var b={};for(var c in a)b[c]=this.buildRules(a[c]);return b},d.prototype.buildRules=function(a){for(var b=a.split("|"),c=[],d=0,e=b.length;e>d;d++){var f=this.parseRule(b[d]),g="required"===f.name?"unshift":"push";c[g](f)}return c},d.prototype.parseRule=function(a){var b=/^(.+?)\[(.+)\]$/.exec(a);return b?{name:b[1],args:b[2]}:{name:a}},d}({})});
!function(a,b){"function"==typeof define&&define.amd?define([],function(){return a.returnExportsGlobal=b()}):"object"==typeof exports?module.exports=b():a.Customs=b()}(this,function(){var a,b,c,d,e,f,g,h;return a=function(a){return"[object Array]"===Object.prototype.toString.call(a)},b=function(a){return function(b){if(a(b))return 0===b.length;for(var c in b)if(b.hasOwnProperty(c))return!1;return!0}}(a),c=function(a,b){return a.replace(/{([^{}]*)}/g,function(a,c){return"string"==typeof b[c]?b[c]:a})},d=function(a){for(var b=1;b<arguments.length;b++)for(var c in arguments[b])a[c]=arguments[b][c];return a},e=function(a){var e=b,f=c,g=d;return{isEmpty:e,tmpl:f,extend:g,createListParser:function(a){var b=this;return function(){return b.listParser.apply(a,arguments)}},listParser:function(a){for(var b=a.split(","),c=0;c<b.length;c++){var d=String(b[c]).replace(/^\s+|\s+$/g,"");if(!this.regex.test(d))return!1}return!0}}}({}),g=function(a){var b=e,c={numeric:/^[0-9]+$/,integer:/^\-?[0-9]+$/,decimal:/^\-?[0-9]*\.?[0-9]+$/,email:/^[a-zA-Z0-9.!#$%&amp;'*+\-\/=?\^_`{|}~\-]+@[a-zA-Z0-9\-]+(?:\.[a-zA-Z0-9\-]+)*$/,alpha:/^[a-z]+$/i,alphaNumeric:/^[a-z0-9]+$/i,alphaDash:/^[a-z0-9_\-]+$/i,natural:/^[0-9]+$/i,naturalNoZero:/^[1-9][0-9]*$/i,ip:/^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})$/i,base64:/[^a-zA-Z0-9\/\+=]/i,numericDash:/^[\d\-\s]+$/,url:/^(https?|s?ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i},d={};d.required={msg:"The {0} field is required.",check:function(a){return null!==a&&"object"==typeof a?!b.isEmpty(a):null!==a&&""!==a}},d["default"]={msg:"The {0} field is still set to default, please change.",check:function(a,b){return a!==b}},d.and={msg:"The {0} field needs to validate all fields in the {1} group.",check:function(){return!0}},d.email={msg:"The {0} field must contain a valid email address.",check:function(a){return c.email.test(a)}},d.minLength={msg:"The {0} field must be at least {1} characters in length.",check:function(a,b){return c.numeric.test(b)?a.length>=parseInt(b,10):!1}},d.maxLength={msg:"The {0} field must not exceed {1} characters in length.",check:function(a,b){return c.numeric.test(b)?a.length<=parseInt(b,10):!1}},d.exactLength={msg:"The {0} field must be exactly {1} characters in length.",check:function(a,b){return c.numeric.test(b)?a.length===parseInt(b,10):!1}},d.greaterThan={msg:"The {0} field must contain a number greater than {1}.",check:function(a,b){return c.decimal.test(a)?parseFloat(a)>parseFloat(b):!1}},d.lessThan={msg:"The {0} field must contain a number less than {1}.",check:function(a,b){return c.decimal.test(a)?parseFloat(a)<parseFloat(b):!1}},d.alpha={msg:"The {0} field must only contain alphabetical characters.",check:function(a){return c.alpha.test(a)}},d.alphaNumeric={msg:"The {0} field must only contain alpha-numeric characters.",check:function(a){return c.alphaNumeric.test(a)}},d.alphaDash={msg:"The {0} field must only contain alpha-numeric characters, underscores, and dashes.",check:function(a){return c.alphaDash.test(a)}},d.numeric={msg:"The {0} field must contain only numbers.",check:function(a){return c.numeric.test(a)}},d.numericDash={msg:"The {0} field must only contain alpha-numeric characters, underscores, and dashes.",check:function(a){return c.numericDash.test(a)}},d.integer={msg:"The {0} field must contain an integer.",check:function(a){return c.integer.test(a)}},d.decimal={msg:"The {0} field must contain a decimal number.",check:function(a){return c.decimal.test(a)}},d.natural={msg:"The {0} field must contain only positive numbers.",check:function(a){return c.natural.test(a)}},d.naturalNoZero={msg:"The {0} field must contain a number greater than zero.",check:function(a){return c.naturalNoZero.test(a)}},d.url={msg:"The {0} field must contain a valid URL.",check:function(a){return c.url.test(a)}},d.creditCard={msg:"The {0} field must contain a valid credit card number.",check:function(a){if(!c.numericDash.test(a))return!1;for(var b=a.replace(/[ -]+/g,""),d=b.length,e=0,f=0,g=[[0,1,2,3,4,5,6,7,8,9],[0,2,4,6,8,1,3,5,7,9]];d--;)f+=g[e][parseInt(b.charAt(d),10)],e^=1;return f%10===0&&f>0}},d.fileType={msg:"The {0} field must contain only {1} files.",check:function(a,b){for(var c=a.substr(a.lastIndexOf(".")+1),d=b.split(","),e=0;e<d.length;e++){var f=String(d[e]).replace(/^\s+|\s+$/g,"");if(c===f)return!0}return!1}},d.equalTo={msg:"The value of {0} does not match the value of {1}.",check:function(a,b,c){return a===c[b]}};for(var f in c){var g=(c[f],f+"s");d[g]={msg:"The {0} field must contain all valid "+g+".",regex:c[f]},d[g].check=b.createListParser(d[g])}return d}({}),h=function(a){var b=e,c=g,d=function(){this.isValid=!0,this.errors={},this.andGroup={},this.andCounter={}};return d.prototype.run=function(a,b){for(var c in a)b[c]&&this.checkRules(c,a[c],b[c],a);for(var d in this.andGroup)this.checkGroups(this.andGroup[d],this.andCounter[d])},d.prototype.checkGroups=function(a,c){if(c.empty===c.count)for(var d in a){var e=a[d];delete this.errors[e]}b.isEmpty(this.errors)&&(this.isValid=!0)},d.prototype.checkRules=function(a,b,c,d){var e=[],f=""===b,g=c[0];if(f&&g&&"required"!==c[0].name)return!0;var h="";for(var i in c){var j=c[i];"default"===j.name&&(h=j.args)}for(i in c){var k=this.checkRule(a,b,c[i],d,h);k&&e.push(k)}e.length&&(this.errors[a]=e)},d.prototype.checkRule=function(a,b,d,e,f){if(!c[d.name])throw new Error("There is no check defined by the name: "+d.name);if("and"===d.name){var g=d.args,h=d.name+"Group",i=this[h][g]||[];i.push(a),this[h][g]=i,h=d.name+"Counter";var j=this[h][g]||{empty:0,count:0};b===f&&j.empty++,j.count++,this[h][g]=j}return c[d.name].check(b,d.args,e)?null:this.formatError(a,d)},d.prototype.formatError=function(a,d){this.isValid=!1;var e=c[d.name].msg,f=[a];return d.args&&(f=f.concat([d.args])),{name:d.name,msg:b.tmpl(e,f)}},d}({}),f=function(a){var b=h,c=g,d=function(a){this.rules=this.build(a)};return d.appendCheck=function(a,b){c[a]=b},d.prototype.check=function(a){var c=new b;return c.run(a,this.rules||{}),{isValid:c.isValid,errors:c.errors}},d.prototype.build=function(a){var b={};for(var c in a)b[c]=this.buildRules(a[c]);return b},d.prototype.buildRules=function(a){for(var b=a.split("|"),c=[],d=0,e=b.length;e>d;d++){var f=this.parseRule(b[d]),g="required"===f.name?"unshift":"push";c[g](f)}return c},d.prototype.parseRule=function(a){var b=/^(.+?)\[(.+)\]$/.exec(a);return b?{name:b[1],args:b[2]}:{name:a}},d}({})});

@@ -5,3 +5,3 @@ {

"author": "Jarid Margolin <jarid@firstopinion.co>",
"version": "0.6.0",
"version": "0.6.1",
"homepage": "https://github.com/jaridmargolin/customs.js",

@@ -8,0 +8,0 @@ "repository": {

@@ -43,3 +43,3 @@ /*!

/**
* @public
* @static
* @memberof Customs

@@ -49,6 +49,12 @@ *

*
* @example
* Customs.appendCheck('truth', {
* 'msg': 'The {0} field must be truthy.',
* 'check': function(val) { return !!val; }
* });
*
* @param {string} name - name of the new check
* @param {object} opts - custom check logic
*/
Customs.prototype.appendCheck = function (name, opts) {
Customs.appendCheck = function (name, opts) {
checks[name] = opts;

@@ -55,0 +61,0 @@ };

@@ -211,7 +211,3 @@ /*!

beforeEach(function () {
this.customs = new Customs({
'bin': 'required|binary'
});
this.customs.appendCheck('binary', {
Customs.appendCheck('binary', {
'msg': 'The {0} field must only contain 0 or 1, binary characters.',

@@ -222,2 +218,6 @@ 'check': function (val) {

});
this.customs = new Customs({
'bin': 'required|binary'
});
});

@@ -224,0 +224,0 @@