UNPKG

jaydata

Version:

Cross-platform HTML5 data-management, JavaScript Language Query (JSLQ) support for OData, SQLite, WebSQL, IndexedDB, YQL and Facebook (packaged for Node.JS)

16 lines (15 loc) 4.9 kB
// JayData 1.5.10 // Dual licensed under MIT and GPL v2 // Copyright JayStack Technologies (http://jaydata.org/licensing) // // JayData is a standards-based, cross-platform Javascript library and a set of // practices to access and manipulate data from various online and offline sources. // // Credits: // Hajnalka Battancs, Dániel József, János Roden, László Horváth, Péter Nochta // Péter Zentai, Róbert Bónay, Szabolcs Czinege, Viktor Borza, Viktor Lázár, // Zoltán Gyebrovszki, Gábor Dolla // // More info: http://jaydata.org !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define("jaydata/modules/validate",["jaydata/core"],e);else{var a;a="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,a.$data=e()}}(function(){return function e(a,t,r){function i(n,d){if(!t[n]){if(!a[n]){var u="function"==typeof require&&require;if(!d&&u)return u(n,!0);if(o)return o(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}var s=t[n]={exports:{}};a[n][0].call(s.exports,function(e){var t=a[n][1][e];return i(t?t:e)},s,s.exports,e,a,t,r)}return t[n].exports}for(var o="function"==typeof require&&require,n=0;n<r.length;n++)i(r[n]);return i}({1:[function(e,a,t){(function(r){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=e("jaydata/core"),n=i(o),d="undefined"!=typeof window?window.jQuery:"undefined"!=typeof r?r.jQuery:null,u=i(d);!function(e,a){var t=e.Validation.Entity,r=function(e){try{return new Date(Date.parse(e))}catch(a){return new Date(0)}},i={required:{key:"required"},customValidator:{key:"customValidator",validateMethod:!0}},n={required:{key:"required"},customValidator:{key:"customValidator",validateMethod:!0},minValue:{key:"min"},maxValue:{key:"max"}},d={"$data.Number":n,"$data.Float":n,"$data.Decimal":n,"$data.Integer":n,"$data.Int16":n,"$data.Int32":n,"$data.Int64":n,"$data.Byte":n,"$data.SByte":n,"$data.String":{required:{key:"required"},customValidator:{key:"customValidator",validateMethod:!0},minLength:{key:"minlength"},maxLength:{key:"maxlength"},length:{key:"length"},regex:{key:"regex",validateMethod:!0}},"$data.Date":{required:{key:"required"},customValidator:{key:"customValidator",validateMethod:!0},minValue:{key:"min",validateMethod:!0,converter:r},maxValue:{key:"max",validateMethod:!0,converter:r}},"$data.DateTimeOffset":{required:{key:"required"},customValidator:{key:"customValidator",validateMethod:!0},minValue:{key:"min",validateMethod:!0,converter:r},maxValue:{key:"max",validateMethod:!0,converter:r}},"$data.Time":{required:{key:"required"},customValidator:{key:"customValidator",validateMethod:!0},minValue:{key:"min"},maxValue:{key:"max"}},"$data.Day":{required:{key:"required"},customValidator:{key:"customValidator",validateMethod:!0},minValue:{key:"min"},maxValue:{key:"max"}},"$data.Duration":{required:{key:"required"},customValidator:{key:"customValidator",validateMethod:!0}},"$data.Array":{required:{key:"required"},customValidator:{key:"customValidator",validateMethod:!0},length:{key:"length",validateMethod:!0}},"$data.Boolean":i,"$data.Object":i},u=function(e,r,i,o){if(e[r]){var n=d[i][r],u=n.key,l=t.getValidationValue(e,r);if(n.validateMethod===!0)return u=e.name+"_"+u,a.validator.addMethod(u,function(e,a){return e||(e=void 0),e&&n.converter&&"function"==typeof n.converter&&(e=n.converter(e)),t.supportedValidations[i][r](e,l)},t.getValidationMessage(e,r,"Validation Error!")),o.rules[e.name]=o.rules[e.name]||{},void(o.rules[e.name][u]=!0);o.rules[e.name]=o.rules[e.name]||{},o.rules[e.name][u]=l;var s=t.getValidationMessage(e,r);s&&(o.messages[e.name]=o.messages[e.name]||{},o.messages[e.name][u]=s)}},l=function(e,a){e.memberDefinitions.getPublicMappedProperties().forEach(function(e){var t=o.Container.resolveName(o.Container.resolveType(e.dataType));if(d[t]){var r=Object.keys(d[t]);r.forEach(function(r){u(e,r,t,a)})}})};e.Entity.prototype.toJQueryValidate=function(t){"undefined"!=typeof a&&"undefined"!=typeof a.validator||o.Guard.raise(new o.Exception("jQuery and jQuery validator plugin is required","Not Found!"));var r=this,i={rules:{},messages:{}};if(l(r.getType(),i),t=e.PromiseHandlerBase.createCallbackSettings(t,{}),t.success){var n=t.success;t.success=function(e,t){a.fn.formBinder&&a(e).formBinder(r,!1),n.apply(this,[r,e,t])}}return"function"==typeof t.success&&(i.submitHandler=t.success),"function"==typeof t.error&&(i.invalidHandler=t.error),i}}(n["default"],u["default"]),t["default"]=n["default"],a.exports=t["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"jaydata/core":"jaydata/core"}]},{},[1])(1)}); //# sourceMappingURL=validate.min.js.map