diff --git a/dist/amd/can-validate.js b/dist/amd/can-validate.js new file mode 100644 index 00000000..0d67fe6d --- /dev/null +++ b/dist/amd/can-validate.js @@ -0,0 +1,98 @@ +/*can-validate@1.1.4#can-validate*/ +define([ + 'require', + 'exports', + 'module', + 'can-reflect' +], function (require, exports, module) { + 'use strict'; + var canReflect = require('can-reflect'); + var validate = {}; + var helpers = { + 'object': function (normalizedErrors) { + var errors = normalizedErrors.length > 0 ? {} : undefined; + canReflect.eachIndex(normalizedErrors, function (error) { + canReflect.eachIndex(error.related, function (related) { + if (!errors[related]) { + errors[related] = []; + } + errors[related].push(error.message); + }); + }); + return errors; + }, + 'flat': function (normalizedErrors) { + var errors = normalizedErrors.length > 0 ? [] : undefined; + canReflect.eachIndex(normalizedErrors, function (error) { + errors.push(error.message); + }); + return errors; + }, + 'errors': function (normalizedErrors) { + return normalizedErrors.length > 0 ? normalizedErrors : undefined; + }, + 'errors-object': function (normalizedErrors) { + var errors = normalizedErrors.length > 0 ? {} : undefined; + canReflect.eachIndex(normalizedErrors, function (error) { + canReflect.eachIndex(error.related, function (related) { + if (!errors[related]) { + errors[related] = []; + } + errors[related].push(error); + }); + }); + return errors; + } + }; + var parseErrorItem = function (rawErrors) { + var errors = []; + if (typeof rawErrors === 'string') { + errors.push({ + message: rawErrors, + related: ['*'] + }); + } + if (typeof rawErrors === 'object' && !Array.isArray(rawErrors)) { + if (rawErrors.related) { + if (!Array.isArray(rawErrors.related)) { + rawErrors.related = [rawErrors.related]; + } + } else { + rawErrors.related = '*'; + } + errors.push(rawErrors); + } + if (Array.isArray(rawErrors)) { + canReflect.eachIndex(rawErrors, function (error) { + [].push.apply(errors, parseErrorItem(error)); + }); + } + return errors; + }; + var normalizeErrors = function (rawErrors) { + var normalizedErrors = []; + if (typeof rawErrors === 'string' || typeof rawErrors === 'object' && !Array.isArray(rawErrors)) { + rawErrors = [rawErrors]; + } + if (rawErrors != null) { + canReflect.eachIndex(rawErrors, function (error) { + [].push.apply(normalizedErrors, parseErrorItem(error)); + }); + } + return normalizedErrors; + }; + validate.formatErrors = function (errors, format) { + var normalized = normalizeErrors(errors); + if (format) { + if (helpers[format]) { + return helpers[format](normalized); + } else { + return normalized; + } + } else { + return normalized; + } + }; + module.exports = validate; +}); +//# sourceMappingURL=can-validate.js.map \ No newline at end of file diff --git a/dist/amd/can-validate.js.map b/dist/amd/can-validate.js.map new file mode 100644 index 00000000..157a2588 --- /dev/null +++ b/dist/amd/can-validate.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../can-validate.js"],"names":["canReflect","require","validate","helpers","normalizedErrors","errors","length","undefined","eachIndex","error","related","push","message","parseErrorItem","rawErrors","Array","isArray","apply","normalizeErrors","formatErrors","format","normalized","module","exports"],"mappings":";;;;;;;IAAA,a;IACA,IAAIA,UAAA,GAAaC,OAAA,CAAQ,aAAR,CAAjB,C;IAEA,IAAIC,QAAA,GAAW,EAAf,C;IAEA,IAAIC,OAAA,GAAU;AAAA,QACb,UAAU,UAAUC,gBAAV,EAA4B;AAAA,YACrC,IAAIC,MAAA,GAASD,gBAAA,CAAiBE,MAAjB,GAA0B,CAA1B,GAA8B,EAA9B,GAAkCC,SAA/C,CADqC;AAAA,YAGrCP,UAAA,CAAWQ,SAAX,CAAqBJ,gBAArB,EAAuC,UAAUK,KAAV,EAAiB;AAAA,gBACvDT,UAAA,CAAWQ,SAAX,CAAqBC,KAAA,CAAMC,OAA3B,EAAoC,UAAUA,OAAV,EAAmB;AAAA,oBACtD,IAAI,CAACL,MAAA,CAAOK,OAAP,CAAL,EAAsB;AAAA,wBACrBL,MAAA,CAAOK,OAAP,IAAkB,EAAlB,CADqB;AAAA,qBADgC;AAAA,oBAItDL,MAAA,CAAOK,OAAP,EAAgBC,IAAhB,CAAqBF,KAAA,CAAMG,OAA3B,EAJsD;AAAA,iBAAvD,EADuD;AAAA,aAAxD,EAHqC;AAAA,YAWrC,OAAOP,MAAP,CAXqC;AAAA,SADzB;AAAA,QAcb,QAAQ,UAAUD,gBA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,GAAY,CAACA,SAAD,CAAZ,CAFE;AAAA,SALuC;AAAA,QAUzC,IAAIA,SAAA,IAAa,IAAjB,EAAuB;AAAA,YACrBd,UAAA,CAAWQ,SAAX,CAAqBM,SAArB,EAAgC,UAAUL,KAAV,EAAiB;AAAA,gBAC/C,GAAGE,IAAH,CAAQM,KAAR,CAAcb,gBAAd,EAAgCS,cAAA,CAAeJ,KAAf,CAAhC,EAD+C;AAAA,aAAjD,EADqB;AAAA,SAVkB;AAAA,QAgB1C,OAAOL,gBAAP,CAhB0C;AAAA,KAA3C,C;IAmBAF,QAAA,CAASiB,YAAT,GAAwB,UAAUd,MAAV,EAAkBe,MAAlB,EAA0B;AAAA,QACjD,IAAIC,UAAA,GAAaH,eAAA,CAAgBb,MAAhB,CAAjB,CADiD;AAAA,QAEjD,IAAIe,MAAJ,EAAY;AAAA,YACX,IAAIjB,OAAA,CAAQiB,MAAR,CAAJ,EAAqB;AAAA,gBACpB,OAAOjB,OAAA,CAAQiB,MAAR,EAAgBC,UAAhB,CAAP,CADoB;AAAA,aAArB,MAEO;AAAA,gBACN,OAAOA,UAAP,CADM;AAAA,aAHI;AAAA,SAAZ,MAMO;AAAA,YACN,OAAOA,UAAP,CADM;AAAA,SAR0C;AAAA,KAAlD,C;IAaAC,MAAA,CAAOC,OAAP,GAAiBrB,QAAjB,C","file":"can-validate.js"} \ No newline at end of file diff --git a/dist/cjs/can-validate.js b/dist/cjs/can-validate.js new file mode 100644 index 00000000..4f87b400 --- /dev/null +++ b/dist/cjs/can-validate.js @@ -0,0 +1,91 @@ +/*can-validate@1.1.4#can-validate*/ +'use strict'; +var canReflect = require('can-reflect'); +var validate = {}; +var helpers = { + 'object': function (normalizedErrors) { + var errors = normalizedErrors.length > 0 ? {} : undefined; + canReflect.eachIndex(normalizedErrors, function (error) { + canReflect.eachIndex(error.related, function (related) { + if (!errors[related]) { + errors[related] = []; + } + errors[related].push(error.message); + }); + }); + return errors; + }, + 'flat': function (normalizedErrors) { + var errors = normalizedErrors.length > 0 ? [] : undefined; + canReflect.eachIndex(normalizedErrors, function (error) { + errors.push(error.message); + }); + return errors; + }, + 'errors': function (normalizedErrors) { + return normalizedErrors.length > 0 ? normalizedErrors : undefined; + }, + 'errors-object': function (normalizedErrors) { + var errors = normalizedErrors.length > 0 ? {} : undefined; + canReflect.eachIndex(normalizedErrors, function (error) { + canReflect.eachIndex(error.related, function (related) { + if (!errors[related]) { + errors[related] = []; + } + errors[related].push(error); + }); + }); + return errors; + } +}; +var parseErrorItem = function (rawErrors) { + var errors = []; + if (typeof rawErrors === 'string') { + errors.push({ + message: rawErrors, + related: ['*'] + }); + } + if (typeof rawErrors === 'object' && !Array.isArray(rawErrors)) { + if (rawErrors.related) { + if (!Array.isArray(rawErrors.related)) { + rawErrors.related = [rawErrors.related]; + } + } else { + rawErrors.related = '*'; + } + errors.push(rawErrors); + } + if (Array.isArray(rawErrors)) { + canReflect.eachIndex(rawErrors, function (error) { + [].push.apply(errors, parseErrorItem(error)); + }); + } + return errors; +}; +var normalizeErrors = function (rawErrors) { + var normalizedErrors = []; + if (typeof rawErrors === 'string' || typeof rawErrors === 'object' && !Array.isArray(rawErrors)) { + rawErrors = [rawErrors]; + } + if (rawErrors != null) { + canReflect.eachIndex(rawErrors, function (error) { + [].push.apply(normalizedErrors, parseErrorItem(error)); + }); + } + return normalizedErrors; +}; +validate.formatErrors = function (errors, format) { + var normalized = normalizeErrors(errors); + if (format) { + if (helpers[format]) { + return helpers[format](normalized); + } else { + return normalized; + } + } else { + return normalized; + } +}; +module.exports = validate; +//# sourceMappingURL=can-validate.js.map \ No newline at end of file diff --git a/dist/cjs/can-validate.js.map b/dist/cjs/can-validate.js.map new file mode 100644 index 00000000..db027540 --- /dev/null +++ b/dist/cjs/can-validate.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../can-validate.js"],"names":["canReflect","require","validate","helpers","normalizedErrors","errors","length","undefined","eachIndex","error","related","push","message","parseErrorItem","rawErrors","Array","isArray","apply","normaliz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IAAIC,UAAA,GAAaH,eAAA,CAAgBb,MAAhB,CAAjB,CADiD;AAAA,IAEjD,IAAIe,MAAJ,EAAY;AAAA,QACX,IAAIjB,OAAA,CAAQiB,MAAR,CAAJ,EAAqB;AAAA,YACpB,OAAOjB,OAAA,CAAQiB,MAAR,EAAgBC,UAAhB,CAAP,CADoB;AAAA,SAArB,MAEO;AAAA,YACN,OAAOA,UAAP,CADM;AAAA,SAHI;AAAA,KAAZ,MAMO;AAAA,QACN,OAAOA,UAAP,CADM;AAAA,KAR0C;AAAA,CAAlD,CAxFA;AAqGAC,MAAA,CAAOC,OAAP,GAAiBrB,QAAjB","file":"can-validate.js"} \ No newline at end of file diff --git a/dist/global/can-validate.js b/dist/global/can-validate.js new file mode 100644 index 00000000..2c1fbd73 --- /dev/null +++ b/dist/global/can-validate.js @@ -0,0 +1,270 @@ +/*[process-shim]*/ +(function(global, env) { + // jshint ignore:line + if (typeof process === "undefined") { + global.process = { + argv: [], + cwd: function() { + return ""; + }, + browser: true, + env: { + NODE_ENV: env || "development" + }, + version: "", + platform: + global.navigator && + global.navigator.userAgent && + /Windows/.test(global.navigator.userAgent) + ? "win" + : "" + }; + } +})( + typeof self == "object" && self.Object == Object + ? self + : typeof process === "object" && + Object.prototype.toString.call(process) === "[object process]" + ? global + : window, + "development" +); + +/*[global-shim-start]*/ +(function(exports, global, doEval) { + // jshint ignore:line + var origDefine = global.define; + + var get = function(name) { + var parts = name.split("."), + cur = global, + i; + for (i = 0; i < parts.length; i++) { + if (!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var set = function(name, val) { + var parts = name.split("."), + cur = global, + i, + part, + next; + for (i = 0; i < parts.length - 1; i++) { + part = parts[i]; + next = cur[part]; + if (!next) { + next = cur[part] = {}; + } + cur = next; + } + part = parts[parts.length - 1]; + cur[part] = val; + }; + var useDefault = function(mod) { + if (!mod || !mod.__esModule) return false; + var esProps = { __esModule: true, default: true }; + for (var p in mod) { + if (!esProps[p]) return false; + } + return true; + }; + + var hasCjsDependencies = function(deps) { + return ( + deps[0] === "require" && deps[1] === "exports" && deps[2] === "module" + ); + }; + + var modules = + (global.define && global.define.modules) || + (global._define && global._define.modules) || + {}; + var ourDefine = (global.define = function(moduleName, deps, callback) { + var module; + if (typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for (i = 0; i < deps.length; i++) { + args.push( + exports[deps[i]] + ? get(exports[deps[i]]) + : modules[deps[i]] || get(deps[i]) + ); + } + // CJS has no dependencies but 3 callback arguments + if (hasCjsDependencies(deps) || (!deps.length && callback.length)) { + module = { exports: {} }; + args[0] = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args[1] = module.exports; + args[2] = module; + } else if (!args[0] && deps[0] === "exports") { + // Babel uses the exports and module object. + module = { exports: {} }; + args[0] = module.exports; + if (deps[1] === "module") { + args[1] = module; + } + } else if (!args[0] && deps[0] === "module") { + args[0] = { id: moduleName }; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + result = module && module.exports ? module.exports : result; + modules[moduleName] = result; + + // Set global exports + var globalExport = exports[moduleName]; + if (globalExport && !get(globalExport)) { + if (useDefault(result)) { + result = result["default"]; + } + set(globalExport, result); + } + }); + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + ourDefine("@loader", [], function() { + // shim for @@global-helpers + var noop = function() {}; + return { + get: function() { + return { prepareGlobal: noop, retrieveGlobal: noop }; + }, + global: global, + __exec: function(__load) { + doEval(__load.source, global); + } + }; + }); +})( + {}, + typeof self == "object" && self.Object == Object + ? self + : typeof process === "object" && + Object.prototype.toString.call(process) === "[object process]" + ? global + : window, + function(__$source__, __$global__) { + // jshint ignore:line + eval("(function() { " + __$source__ + " \n }).call(__$global__);"); + } +); + +/*can-validate@1.1.4#can-validate*/ +define('can-validate', [ + 'require', + 'exports', + 'module', + 'can-reflect' +], function (require, exports, module) { + 'use strict'; + var canReflect = require('can-reflect'); + var validate = {}; + var helpers = { + 'object': function (normalizedErrors) { + var errors = normalizedErrors.length > 0 ? {} : undefined; + canReflect.eachIndex(normalizedErrors, function (error) { + canReflect.eachIndex(error.related, function (related) { + if (!errors[related]) { + errors[related] = []; + } + errors[related].push(error.message); + }); + }); + return errors; + }, + 'flat': function (normalizedErrors) { + var errors = normalizedErrors.length > 0 ? [] : undefined; + canReflect.eachIndex(normalizedErrors, function (error) { + errors.push(error.message); + }); + return errors; + }, + 'errors': function (normalizedErrors) { + return normalizedErrors.length > 0 ? normalizedErrors : undefined; + }, + 'errors-object': function (normalizedErrors) { + var errors = normalizedErrors.length > 0 ? {} : undefined; + canReflect.eachIndex(normalizedErrors, function (error) { + canReflect.eachIndex(error.related, function (related) { + if (!errors[related]) { + errors[related] = []; + } + errors[related].push(error); + }); + }); + return errors; + } + }; + var parseErrorItem = function (rawErrors) { + var errors = []; + if (typeof rawErrors === 'string') { + errors.push({ + message: rawErrors, + related: ['*'] + }); + } + if (typeof rawErrors === 'object' && !Array.isArray(rawErrors)) { + if (rawErrors.related) { + if (!Array.isArray(rawErrors.related)) { + rawErrors.related = [rawErrors.related]; + } + } else { + rawErrors.related = '*'; + } + errors.push(rawErrors); + } + if (Array.isArray(rawErrors)) { + canReflect.eachIndex(rawErrors, function (error) { + [].push.apply(errors, parseErrorItem(error)); + }); + } + return errors; + }; + var normalizeErrors = function (rawErrors) { + var normalizedErrors = []; + if (typeof rawErrors === 'string' || typeof rawErrors === 'object' && !Array.isArray(rawErrors)) { + rawErrors = [rawErrors]; + } + if (rawErrors != null) { + canReflect.eachIndex(rawErrors, function (error) { + [].push.apply(normalizedErrors, parseErrorItem(error)); + }); + } + return normalizedErrors; + }; + validate.formatErrors = function (errors, format) { + var normalized = normalizeErrors(errors); + if (format) { + if (helpers[format]) { + return helpers[format](normalized); + } else { + return normalized; + } + } else { + return normalized; + } + }; + module.exports = validate; +}); +/*[global-shim-end]*/ +(function(global) { // jshint ignore:line + global._define = global.define; + global.define = global.define.orig; +} +)(typeof self == "object" && self.Object == Object ? self : (typeof process === "object" && Object.prototype.toString.call(process) === "[object process]") ? global : window); +//# sourceMappingURL=can-validate.js.map \ No newline at end of file diff --git a/dist/global/can-validate.js.map b/dist/global/can-validate.js.map new file mode 100644 index 00000000..4a030b62 --- /dev/null +++ b/dist/global/can-validate.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../can-validate.js"],"names":["canReflect","require","validate","helpers","normalizedErrors","errors","length","undefined","eachIndex","error","related","push","message","parseErrorItem","rawErrors","Array","isArray","apply","normalizeErrors","formatErrors","format","normalized","module","exports"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAA,a;IACA,IAAIA,UAAA,GAAaC,OAAA,CAAQ,aAAR,CAAjB,C;IAEA,IAAIC,QAAA,GAAW,EAAf,C;IAEA,IAAIC,OAAA,GAAU;AAAA,QACb,UAAU,UAAUC,gBAAV,EAA4B;AAAA,YACrC,IAAIC,MAAA,GAASD,gBAAA,CAAiBE,MAAjB,GAA0B,CAA1B,GAA8B,EAA9B,GAAkCC,SAA/C,CADqC;AAAA,YAGrCP,UAAA,CAAWQ,SAAX,CAAqBJ,gBAArB,EAAuC,UAAUK,KAAV,EAAiB;AAAA,gBACvDT,UAAA,CAAWQ,SAAX,CAAqBC,KAAA,CAAMC,OAA3B,EAAoC,UAAUA,OAAV,EAAmB;AAAA,oBACtD,IAAI,CAACL,MAAA,CAAOK,OAAP,CAAL,EAAsB;AAAA,wBACrBL,MAAA,CAAOK,OAAP,IAAkB,EAAlB,CADqB;AAAA,qBADgC;AAAA,oBAItDL,MAAA,CAAOK,OAAP,EAAgBC,IAAhB,CAAqBF,KAAA,CAAMG,OAA3B,EAJsD;AA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