UNPKG

type-r2

Version:

Serializable, validated, and observable data layer for modern JS applications

3 lines (2 loc) 2.48 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("type-r")):"function"==typeof define&&define.amd?define(["exports","type-r"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).NestedExtTypes={},t.Nested)}(this,function(t,a){"use strict";var i=function(t,e){return(i=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}))(t,e)};var f=/\/Date\(([0-9]+)\)\//,e=function(t){var e=n,r=t;if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function o(){this.constructor=e}function n(){return null!==t&&t.apply(this,arguments)||this}return i(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o),n.prototype.convert=function(t){if("string"==typeof t){t=f.exec(t);if(t)return new Date(Number(t[1]))}return a.DateType.prototype.convert.apply(this,arguments)},n.prototype.toJSON=function(t){return t&&"/Date(".concat(t.getTime(),")/")},n}(a.DateType),r=new a.ChainableAttributeSpec({type:Date,_metatype:e}),o=a.type(Date).toJSON(function(t){return t&&t.getTime()});function n(t){return t?Math.round(t):0}n._metatype=a.NumericType;var u=/^(?:(?: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;function p(t){return!t||u.test(t)}p.error="Not valid URL";var c=a.type(String).check(p),d=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;function s(t){return!t||d.test(t)}s.error="Not valid IP address";var y=a.type(String).check(s),l=/^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i;function m(t){return!t||!!t.match(l)}m.error="Not valid email";var h=a.type(String).check(m);t.Email=h,t.IPAddress=y,t.Integer=n,t.MicrosoftDate=r,t.MicrosoftDateType=e,t.Timestamp=o,t.Url=c,t.isEmail=m,t.isIPAddress=s,t.isUrl=p}); //# sourceMappingURL=index.js.map