-
Notifications
You must be signed in to change notification settings - Fork 0
/
is.min.js
8 lines (8 loc) · 1.72 KB
/
is.min.js
1
2
3
4
5
6
7
8
// ============================================================================
// is.js 1.0.0
// ============================================================================
// > http://wyattkirby.com/is
// > (c) 2013 Wyatt Kirby
// > is.js may be freely distributed under the MIT License.
// ============================================================================
(function(){"use strict";var e=this,t=t||{};e.is=t;t.VERSION="1.0.0";var n=new RegExp("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,253}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,253}[a-zA-Z0-9])?)*$"),r=new RegExp("^(?:https?://|wwwd{0,3}[.]|[a-z0-9.-]+[.][a-z]{2,4}/)(?:[^s()<>]+|(([^s()<>]+|(([^s()<>]+)))*))+(?:(([^s()<>]+|(([^s()<>]+)))*)|[^s`!()[]{};:'\".,<>?«»“”‘’])$"),i=new RegExp("^(([1-9])|(0[1-9])|(1[0-2]))\\/((0[1-9])|([1-31]))\\/((\\d{2})|(\\d{4}))$"),s=new RegExp("^\\D?(\\d{3})\\D?\\D?(\\d{3})\\D?(\\d{4})$"),o=function(e,t){return!e||!t?!1:t.test(e)};t.email=function(e){return o(e,n)};t.url=function(e){return o(e,r)};t.date=function(e){return o(e,i)};t.phone=function(e){return o(e,s)};t.string=function(e){return typeof e=="string"||e instanceof String};t.number=function(e){return typeof e=="number"||e instanceof Number};t.bool=function(e){return e===!!e||e instanceof Boolean};t.array=function(e){return typeof e=="array"||e instanceof Array};t.wholeNum=function(e){var n=parseInt(e,10);return t.number(n)&&!isNaN(n)&&n%1===0?!0:!1};t.even=function(e){var n=parseInt(e,10);return t.number(n)&&n%2===0?!0:!1};t.odd=function(e){return!t.even(e)};t.setEmailRegex=function(e){n=new RegExp(e)};t.setURLRegex=function(e){r=new RegExp(e)};t.setDateRegex=function(e){i=new RegExp(e)};t.setPhoneRegex=function(e){s=new RegExp(e)}}).call(this);