@aofl/form-validate
Advanced tools
Comparing version 3.12.1 to 3.13.0
@@ -1,2 +0,2 @@ | ||
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s="QfWi")}({"86LY":function(e,t){e.exports=require("@babel/runtime/helpers/possibleConstructorReturn")},MmcY:function(e,t){e.exports=require("@babel/runtime/helpers/classCallCheck")},QfWi:function(e,t,n){"use strict";n.r(t),n.d(t,"validationMixin",(function(){return O})),n.d(t,"isAllDigits",(function(){return w})),n.d(t,"isEqual",(function(){return C})),n.d(t,"minLength",(function(){return x})),n.d(t,"maxLength",(function(){return k})),n.d(t,"isRequired",(function(){return S})),n.d(t,"ValidationFunction",(function(){return y})),n.d(t,"ValidationProperty",(function(){return g})),n.d(t,"pattern",(function(){return q})),n.d(t,"compare",(function(){return j}));var r=n("MmcY"),i=n.n(r),o=n("86LY"),s=n.n(o),a=n("a4YD"),l=n.n(a),u=n("ZmRK"),c=n.n(u),f=n("cB7G"),h=n.n(f),p=n("mdGc"),d=n.n(p),v=n("iTvO"),b=n.n(v),m=n("l3wB"),y=function(){function e(t,n,r){i()(this,e),Object.defineProperties(this,{target:{value:t},path:{value:r},propName:{value:r.split(".").slice(0,-1).join(".")},resolve:{writable:!0},cachedPromise:{writable:!0},validateCompletePromise:{writable:!0},valid:{writable:!0},observed:{writable:!0},pending:{writable:!0},validatorFn:{value:n}}),this.reset()}return b()(e,[{key:"reset",value:function(){this.cachedPromise=null,this.resolve=null,this.valid=!0,this.observed=!1,this.pending=!1,this.validateCompletePromise=null}},{key:"validate",value:function(){var e=this;this.observed=!0;var t=Object(m.get)(this.target,this.propName),n=Promise.resolve(this.validatorFn(t,this.target));this.cachedPromise=n,!1===this.pending&&(this.validateCompletePromise=new Promise((function(t){e.resolve=t}))),this.pending=!0,n.then((function(t){e.cachedPromise===n&&(e.valid=t,e.pending=!1,e.resolve(),e.target.requestUpdate())}))}},{key:"getKeys",value:function(){var e=["valid","pending","observed"];for(var t in this)Object.prototype.hasOwnProperty.call(this,t)&&e.push(t);return e}},{key:"toString",value:function(){var e=this.getKeys();return JSON.stringify(this,e,2)}},{key:"validateComplete",get:function(){return this.validateCompletePromise}}]),e}(),g=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";for(var o in i()(this,e),Object.defineProperty(this,"resolve",{writable:!0}),Object.defineProperty(this,"validateCompleteResolved",{writable:!0}),Object.defineProperty(this,"validateCompletePromise",{writable:!0}),n)if(Object.prototype.hasOwnProperty.call(n,o)){if(Object.prototype.hasOwnProperty.call(this,o))throw new Error("".concat(o," is a reserved keyword and cannot be used as a validator name."));var s=r;0===s.length?s=o:s+="."+o,"function"==typeof n[o]?this[o]=new y(t,n[o],s):this[o]=new e(t,n[o],s)}this.reset()}return b()(e,[{key:"reset",value:function(){var t=this;for(var n in this.validateCompletePromise=new Promise((function(e){t.resolve=e})),this.validateCompleteResolved=!1,this)Object.prototype.hasOwnProperty.call(this,n)&&(this[n]instanceof e||this[n]instanceof y)&&this[n].reset()}},{key:"validate",value:function(){for(var t in this)Object.prototype.hasOwnProperty.call(this,t)&&(this[t]instanceof e||this[t]instanceof y)&&this[t].validate()}},{key:"getKeys",value:function(){var e=["valid","pending","observed"];for(var t in this)Object.prototype.hasOwnProperty.call(this,t)&&(e.push(t),e.push.apply(e,d()(this[t].getKeys())));return e}},{key:"toString",value:function(){var e=this.getKeys();return JSON.stringify(this,e,2)}},{key:"valid",get:function(){for(var t in this)if(Object.prototype.hasOwnProperty.call(this,t)&&(this[t]instanceof e||this[t]instanceof y)&&!1===this[t].valid)return!1;return!0}},{key:"pending",get:function(){for(var t in this)if(Object.prototype.hasOwnProperty.call(this,t)&&(this[t]instanceof e||this[t]instanceof y)&&!0===this[t].pending)return!0;return!1}},{key:"observed",get:function(){for(var t in this)if(Object.prototype.hasOwnProperty.call(this,t)&&(this[t]instanceof e||this[t]instanceof y)&&!0===this[t].observed)return!0;return!1}},{key:"validateComplete",get:function(){var e=this;this.pending&&this.validateCompleteResolved&&(this.validateCompleteResolved=!1,this.validateCompletePromise=new Promise((function(t){e.resolve=t})));return function t(){var n=Object.keys(e).map((function(t){return e[t].validateComplete}));Promise.all(n).then((function(){if(e.pending)return t();e.resolve(),e.validateCompleteResolved=!0}))}(),this.validateCompletePromise}}]),e}(),O=function(e){return function(e){function t(){var e,n;i()(this,t);for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];n=s()(this,(e=l()(t)).call.apply(e,[this].concat(o)));var u=void 0;return Object.defineProperties(c()(n),{validators:{get:function(){return u},set:function(e){void 0===u&&(u=e,this.form=new g(this,e))}},form:{writable:!0,enumerable:!0}}),n}return h()(t,e),t}(e)},P=/^[0-9]+$/,w=function(e){return Boolean(e&&P.test(String(e)))},j=function(e,t){return function(n,r){var i=Object(m.get)(r,e);return void 0!==i&&t(n,i)}},C=function(e){return j(e,(function(e,t){return Boolean(e&&e===t)}))},x=function(e){return function(t){return!!t&&(void 0===t.length&&(t=String(t)),Boolean(t.length>=e))}},k=function(e){return function(t){return!!t&&(void 0===t.length&&(t=String(t)),Boolean(t.length<=e))}};function S(e){return Boolean(e&&""!==String(e))}var q=function(e,t){return e instanceof RegExp||(e=new RegExp(e,t)),function(t){return e.test(String(t))}}},ZmRK:function(e,t){e.exports=require("@babel/runtime/helpers/assertThisInitialized")},a4YD:function(e,t){e.exports=require("@babel/runtime/helpers/getPrototypeOf")},cB7G:function(e,t){e.exports=require("@babel/runtime/helpers/inherits")},iTvO:function(e,t){e.exports=require("@babel/runtime/helpers/createClass")},l3wB:function(e,t){e.exports=require("@aofl/object-utils")},mdGc:function(e,t){e.exports=require("@babel/runtime/helpers/toConsumableArray")}}); | ||
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s="QfWi")}({"86LY":function(e,t){e.exports=require("@babel/runtime/helpers/possibleConstructorReturn")},MmcY:function(e,t){e.exports=require("@babel/runtime/helpers/classCallCheck")},QfWi:function(e,t,n){"use strict";n.r(t),n.d(t,"validationMixin",(function(){return P})),n.d(t,"isAllDigits",(function(){return j})),n.d(t,"isEqual",(function(){return x})),n.d(t,"minLength",(function(){return k})),n.d(t,"maxLength",(function(){return R})),n.d(t,"isRequired",(function(){return S})),n.d(t,"ValidationFunction",(function(){return m})),n.d(t,"ValidationProperty",(function(){return g})),n.d(t,"pattern",(function(){return q})),n.d(t,"compare",(function(){return C}));var r=n("MmcY"),i=n.n(r),o=n("ZmRK"),a=n.n(o),s=n("cB7G"),u=n.n(s),l=n("86LY"),c=n.n(l),f=n("a4YD"),h=n.n(f),p=n("mdGc"),v=n.n(p),d=n("iTvO"),y=n.n(d),b=n("l3wB"),m=function(){function e(t,n,r){i()(this,e),Object.defineProperties(this,{target:{value:t},path:{value:r},propName:{value:r.split(".").slice(0,-1).join(".")},resolve:{writable:!0},cachedPromise:{writable:!0},validateCompletePromise:{writable:!0},valid:{writable:!0},observed:{writable:!0},pending:{writable:!0},validatorFn:{value:n}}),this.reset()}return y()(e,[{key:"reset",value:function(){this.cachedPromise=null,this.resolve=null,this.valid=!0,this.observed=!1,this.pending=!1,this.validateCompletePromise=null}},{key:"validate",value:function(){var e=this;this.observed=!0;var t=Object(b.get)(this.target,this.propName),n=Promise.resolve(this.validatorFn(t,this.target));this.cachedPromise=n,!1===this.pending&&(this.validateCompletePromise=new Promise((function(t){e.resolve=t}))),this.pending=!0,n.then((function(t){e.cachedPromise===n&&(e.valid=t,e.pending=!1,e.resolve(),e.target.requestUpdate())}))}},{key:"validateComplete",get:function(){return this.validateCompletePromise}},{key:"getKeys",value:function(){var e=["valid","pending","observed"];for(var t in this)Object.prototype.hasOwnProperty.call(this,t)&&e.push(t);return e}},{key:"toString",value:function(){var e=this.getKeys();return JSON.stringify(this,e,2)}}]),e}(),g=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";for(var o in i()(this,e),Object.defineProperty(this,"resolve",{writable:!0}),Object.defineProperty(this,"validateCompleteResolved",{writable:!0}),Object.defineProperty(this,"validateCompletePromise",{writable:!0}),n)if(Object.prototype.hasOwnProperty.call(n,o)){if(Object.prototype.hasOwnProperty.call(this,o))throw new Error("".concat(o," is a reserved keyword and cannot be used as a validator name."));var a=r;0===a.length?a=o:a+="."+o,"function"==typeof n[o]?this[o]=new m(t,n[o],a):this[o]=new e(t,n[o],a)}this.reset()}return y()(e,[{key:"reset",value:function(){var t=this;for(var n in this.validateCompletePromise=new Promise((function(e){t.resolve=e})),this.validateCompleteResolved=!1,this)Object.prototype.hasOwnProperty.call(this,n)&&(this[n]instanceof e||this[n]instanceof m)&&this[n].reset()}},{key:"valid",get:function(){for(var t in this)if(Object.prototype.hasOwnProperty.call(this,t)&&(this[t]instanceof e||this[t]instanceof m)&&!1===this[t].valid)return!1;return!0}},{key:"pending",get:function(){for(var t in this)if(Object.prototype.hasOwnProperty.call(this,t)&&(this[t]instanceof e||this[t]instanceof m)&&!0===this[t].pending)return!0;return!1}},{key:"observed",get:function(){for(var t in this)if(Object.prototype.hasOwnProperty.call(this,t)&&(this[t]instanceof e||this[t]instanceof m)&&!0===this[t].observed)return!0;return!1}},{key:"validate",value:function(){for(var t in this)Object.prototype.hasOwnProperty.call(this,t)&&(this[t]instanceof e||this[t]instanceof m)&&this[t].validate()}},{key:"validateComplete",get:function(){var e=this;this.pending&&this.validateCompleteResolved&&(this.validateCompleteResolved=!1,this.validateCompletePromise=new Promise((function(t){e.resolve=t})));return function t(){var n=Object.keys(e).map((function(t){return e[t].validateComplete}));Promise.all(n).then((function(){if(e.pending)return t();e.resolve(),e.validateCompleteResolved=!0}))}(),this.validateCompletePromise}},{key:"getKeys",value:function(){var e=["valid","pending","observed"];for(var t in this)Object.prototype.hasOwnProperty.call(this,t)&&(e.push(t),e.push.apply(e,v()(this[t].getKeys())));return e}},{key:"toString",value:function(){var e=this.getKeys();return JSON.stringify(this,e,2)}}]),e}();function O(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=h()(e);if(t){var i=h()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return c()(this,n)}}var P=function(e){return function(e){u()(n,e);var t=O(n);function n(){var e;i()(this,n);for(var r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];e=t.call.apply(t,[this].concat(o));var u=void 0;return Object.defineProperties(a()(e),{validators:{get:function(){return u},set:function(e){void 0===u&&(u=e,this.form=new g(this,e))}},form:{writable:!0,enumerable:!0}}),e}return n}(e)},w=/^[0-9]+$/,j=function(e){return Boolean(e&&w.test(String(e)))},C=function(e,t){return function(n,r){var i=Object(b.get)(r,e);return void 0!==i&&t(n,i)}},x=function(e){return C(e,(function(e,t){return Boolean(e&&e===t)}))},k=function(e){return function(t){return!!t&&(void 0===t.length&&(t=String(t)),Boolean(t.length>=e))}},R=function(e){return function(t){return!!t&&(void 0===t.length&&(t=String(t)),Boolean(t.length<=e))}};function S(e){return Boolean(e&&""!==String(e))}var q=function(e,t){return e instanceof RegExp||(e=new RegExp(e,t)),function(t){return e.test(String(t))}}},ZmRK:function(e,t){e.exports=require("@babel/runtime/helpers/assertThisInitialized")},a4YD:function(e,t){e.exports=require("@babel/runtime/helpers/getPrototypeOf")},cB7G:function(e,t){e.exports=require("@babel/runtime/helpers/inherits")},iTvO:function(e,t){e.exports=require("@babel/runtime/helpers/createClass")},l3wB:function(e,t){e.exports=require("@aofl/object-utils")},mdGc:function(e,t){e.exports=require("@babel/runtime/helpers/toConsumableArray")}}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@aofl/form-validate", | ||
"version": "3.12.1", | ||
"version": "3.13.0", | ||
"description": "Form validation mixin for AoflElement", | ||
@@ -41,4 +41,4 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@aofl/cli": "^3.12.1", | ||
"@aofl/object-utils": "^3.12.1", | ||
"@aofl/cli": "^3.13.0", | ||
"@aofl/object-utils": "^3.13.0", | ||
"cross-env": "^6.0.3", | ||
@@ -45,0 +45,0 @@ "jsdoc": "^3.6.3", |
116
types.d.ts
/** | ||
* Exports the ValidationMixin and some commonly needed validations | ||
* | ||
* @module @aofl/form-validate | ||
* @version 3.0.0 | ||
* @since 1.0.0 | ||
* @author Arian Khosravi <arian.khosravi@aofl.com> | ||
*/ | ||
@@ -12,9 +7,3 @@ declare module "@aofl/form-validate" { | ||
* Tracks two properties of any class to be equal. | ||
* | ||
* @memberof module:@aofl/form-validate | ||
* | ||
* @param {String} propPath | ||
* @param {Function} comparator | ||
* | ||
* @return {Function} True or false if the given value passes the | ||
* @returns True or false if the given value passes the | ||
* given regex test is valid. | ||
@@ -25,8 +14,2 @@ */ | ||
* Checks to see if a given value is all digits or not. | ||
* | ||
* @memberof module:@aofl/form-validate | ||
* | ||
* @param {String} value | ||
* | ||
* @return {boolean} | ||
*/ | ||
@@ -36,8 +19,3 @@ function isAllDigits(value: string): boolean; | ||
* Tracks two properties of any class to be equal. | ||
* | ||
* @memberof module:@aofl/form-validate | ||
* | ||
* @param {String} propPath | ||
* | ||
* @return {Function} True or false if the given value passes the | ||
* @returns True or false if the given value passes the | ||
* given regex test is valid. | ||
@@ -48,7 +26,2 @@ */ | ||
* isRequired | ||
* | ||
* @memberof module:@aofl/form-validate | ||
* | ||
* @param {String} value | ||
* @return {Boolean} | ||
*/ | ||
@@ -58,7 +31,3 @@ function isRequired(value: string): boolean; | ||
* Checks to see if the given value meets the minimum length given. | ||
* | ||
* @memberof module:@aofl/form-validate | ||
* | ||
* @param {Number} length The min length | ||
* @return {Function} | ||
* @param length - The min length | ||
*/ | ||
@@ -68,7 +37,3 @@ function minLength(length: number): (...params: any[]) => any; | ||
* Checks to see if the given value meets the maximum length given. | ||
* | ||
* @memberof module:@aofl/form-validate | ||
* @param {Number} length The max length | ||
* @return {Function} | ||
* @param length - The max length | ||
*/ | ||
@@ -78,9 +43,3 @@ function maxLength(length: number): (...params: any[]) => any; | ||
* Tests if input matches the given pattern. | ||
* | ||
* @memberof module:@aofl/form-validate | ||
* | ||
* @param {String|RegExp} regex | ||
* @param {String} flags | ||
* | ||
* @return {Function} True or false if the given value passes the | ||
* @returns True or false if the given value passes the | ||
* given regex test is valid. | ||
@@ -91,38 +50,11 @@ */ | ||
* Creates an instance of ValidationFunction. | ||
* | ||
* @param {Object} target | ||
* @param {Object} validatorFn | ||
* @param {String} path | ||
*/ | ||
class ValidationFunction { | ||
constructor(target: any, validatorFn: any, path: string); | ||
/** | ||
* | ||
*/ | ||
reset(): void; | ||
/** | ||
* | ||
* | ||
*/ | ||
validate(): void; | ||
/** | ||
* @type {Promise} | ||
*/ | ||
validateComplete: Promise; | ||
/** | ||
* | ||
* @return {Array} | ||
*/ | ||
getKeys(): any[]; | ||
/** | ||
* @return {String} | ||
*/ | ||
toString(): string; | ||
} | ||
/** | ||
* @memberof module:@aofl/form-validate | ||
* | ||
* @param {Object} superClass | ||
* @return {ValidationMixin} | ||
*/ | ||
function validationMixin(superClass: any): ValidationMixin; | ||
@@ -136,50 +68,12 @@ /** | ||
* Creates an instance of ValidationProperty. | ||
* | ||
* @param {Object} target | ||
* @param {Object} validators | ||
* @param {String} _propName | ||
*/ | ||
class ValidationProperty { | ||
constructor(target: any, validators: any, _propName: string); | ||
/** | ||
* | ||
*/ | ||
reset(): void; | ||
/** | ||
* | ||
* @readonly | ||
* @type {Boolean} | ||
*/ | ||
readonly valid: boolean; | ||
/** | ||
* | ||
* @readonly | ||
* @type {Boolean} | ||
*/ | ||
readonly pending: boolean; | ||
/** | ||
* | ||
* @readonly | ||
* @type {Boolean} | ||
*/ | ||
readonly observed: boolean; | ||
/** | ||
* | ||
* | ||
*/ | ||
validate(): void; | ||
/** | ||
* | ||
* @readonly | ||
* @type {Promise} | ||
*/ | ||
readonly validateComplete: Promise; | ||
/** | ||
* | ||
* @return {Array} | ||
*/ | ||
getKeys(): any[]; | ||
/** | ||
* @return {String} | ||
*/ | ||
toString(): string; | ||
@@ -186,0 +80,0 @@ } |
Sorry, the diff of this file is not supported yet
54018
648