From 30e39e4f7022a8120b27b42df57d007ebb0fd474 Mon Sep 17 00:00:00 2001 From: Maxim Kerstens Date: Sun, 19 Jun 2016 00:34:39 +0200 Subject: [PATCH] Finished image dimensions validation rule --- dist/laravel-parsley.js | 145 +++++++++++++++----------------- dist/laravel-parsley.js.map | 2 +- dist/laravel-parsley.min.js | 4 +- dist/laravel-parsley.min.js.map | 2 +- index.html | 103 ++++++++++++++++++++++- package.json | 2 +- src/rules/files.js | 143 +++++++++++++++---------------- 7 files changed, 240 insertions(+), 161 deletions(-) diff --git a/dist/laravel-parsley.js b/dist/laravel-parsley.js index e21f867..0173135 100644 --- a/dist/laravel-parsley.js +++ b/dist/laravel-parsley.js @@ -1,6 +1,6 @@ /*! * ParsleyJS-LaraExtras.js - * Version 0.4.0 - built Sun, Jun 19th 2016, 12:01 am + * Version 0.4.1 - built Sun, Jun 19th 2016, 12:34 am * hhttps://github.com/happyDemon/ParsleyJS-LaraExtras * Maxim Kerstens - * MIT Licensed @@ -748,9 +748,6 @@ }); // Make sure all images withing the input have specific dimensions - - //Parsley.addAsyncValidator(); - window.Parsley.addValidator('dimensions', { requirementType: { '': 'boolean', @@ -762,108 +759,102 @@ height: 'number', // Specify the height the image should have ratio: 'string' }, // Specify the ratio the image should have - validateString: function validateString(value, param, options, parsleyFieldInstance) { + validateString: function validateString(value, param, parsleyFieldInstance) { var files = parsleyFieldInstance.$element[0].files; + var options = parsleyFieldInstance.domOptions.dimensionsOptions; + // If a file is present in the input if (files.length > 0) { var defer = jQuery.Deferred(); + var _URL = window.URL || window.webkitURL; - var file = new FileReader(); - - // Set up the image validation when the file is loaded - file.onload = function () { - var image = new Image(); + var image = new Image(); - // Validate once t he image is loaded - image.onload = function () { - var width = this.width; - var height = this.height; + // Validate once t he image is loaded + image.onload = function () { + var width = this.width; + var height = this.height; - // Check min width, if defined - if (typeof options.min_width != 'undefined') { - console.log(width, options.min_width); - if (width < options.min_width) { - defer.reject(); - return; - } + // Check min width, if defined + if (typeof options.min_width != 'undefined') { + if (width < options.min_width) { + defer.reject(image); + return true; } + } - // Check max width, if defined - if (typeof options.max_width != 'undefined') { - if (width > options.max_width) { - defer.reject(); - return; - } + // Check max width, if defined + if (typeof options.max_width != 'undefined') { + if (width > options.max_width) { + defer.reject(image); + return true; } + } - // Check min height, if defined - if (typeof options.min_height != 'undefined') { - if (height < options.min_height) { - defer.reject(); - return; - } + // Check min height, if defined + if (typeof options.min_height != 'undefined') { + if (height < options.min_height) { + defer.reject(image); + return true; } + } - // Check max height, if defined - if (typeof options.max_height != 'undefined') { - if (height > options.max_height) { - defer.reject(); - return; - } + // Check max height, if defined + if (typeof options.max_height != 'undefined') { + if (height > options.max_height) { + defer.reject(image); + return true; } + } - // Check width, if defined - if (typeof options.width != 'undefined') { - if (width != options.width) { - defer.reject(); - return; - } + // Check width, if defined + if (typeof options.width != 'undefined') { + if (width != options.width) { + defer.reject(image); + return true; } + } - // Check height, if defined - if (typeof options.height != 'undefined') { - if (height != options.height) { - defer.reject(); - return; - } + // Check height, if defined + if (typeof options.height != 'undefined') { + if (height != options.height) { + defer.reject(image); + return true; } + } - // Check ratio, if defined - if (typeof options.ratio != 'undefined') { - var splitRatio = options.ratio.split(':'); - - if (splitRatio[0] / splitRatio[1] != width / height) { - defer.reject(); - return; - } + // Check ratio, if defined + if (typeof options.ratio != 'undefined') { + var splitRatio = options.ratio.split(':'); + if (splitRatio[0] / splitRatio[1] != width / height) { + defer.reject(image); + return true; } + } - defer.resolve(); - }; - - // On error, reject the promise - image.onerror = function () { - console.log('image error'); - defer.reject(); - }; - - // Set the image - console.log(file.result); - image.src = file.result; + defer.resolve(image); }; // On error, reject the promise - file.onerror = function () { - console.log('file error'); + image.onerror = function () { + console.warn('image load error'); defer.reject(); }; - // Set the file - console.log(files[0]); - file.readAsDataURL(files[0]); + image.src = _URL.createObjectURL(files[0]); - return defer.promise(); + return defer.promise().then(function (image) { + // Clean up + image = null; + + return true; + }, function (image) { + // Clean up + image = null; + + return false; + }); } return true; diff --git a/dist/laravel-parsley.js.map b/dist/laravel-parsley.js.map index 8641bb6..6504ae4 100644 --- a/dist/laravel-parsley.js.map +++ b/dist/laravel-parsley.js.map @@ -1 +1 @@ -{"version":3,"sources":["laravel-parsley.js","src/rules/ins.js","src/rules/dates.js","src/utils.js","src/rules/comparison.js","src/rules/requireds.js","src/rules/files.js","src/main.js"],"names":[],"mappings":";;;;;;;;;;;AAAA,AAAC,CAAA,UAAU,MAAM,EAAE,OAAO,EAAE;AACxB,WAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,WAAW,GAAG,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,GAC7H,OAAO,MAAM,KAAK,UAAU,IAAI,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,GAClF,MAAM,CAAC,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;CAC7D,CAAA,CAAC,IAAI,EAAE,UAAU,MAAM,EAAE,MAAM,EAAE;AAAE,gBAAY,CAAC;;;ACHjD,UAAA,CAAO,OAAA,CACF,YAAA,CAAa,IAAA,EAAM;AAChB,uBAAA,EAAiB,QAAA;AACjB,sBAAA,EAAgB,wBAAU,KAAA,EAAO,SAAA,EAAW;AACxC,gBAAI,SAAA,GAAY,SAAA,CAAU,KAAA,CAAM,GAAA,CAAA,CAAA;;AAEhC,mBAAO,SAAA,CAAU,OAAA,CAAQ,KAAA,CAAA,GAAS,CAAC,CAAA,CAAA;SAC/C;AACQ,gBAAA,EAAU;AACN,cAAA,EAAI,iDAAA;SAChB;KACA,CAAA,CAAA;;;AAGA,UAAA,CAAO,OAAA,CACF,YAAA,CAAa,OAAA,EAAS;AACnB,uBAAA,EAAiB,QAAA;AACjB,sBAAA,EAAgB,wBAAU,KAA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esContent":["(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('moment')) :\n typeof define === 'function' && define.amd ? define(['jquery', 'moment'], factory) :\n global.laraParsley = factory(global.jQuery, global.moment)\n}(this, function (jQuery, moment) { 'use strict';\n\n // Check if the value is within a comma-separated list (val1,val2,..)\n window.Parsley\n .addValidator('in', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n var possibles = parameter.split(',');\n\n return possibles.indexOf(value) > -1;\n },\n messages: {\n en: 'The value should be one of the following: \"%s\".'\n }\n });\n\n // Check if the value is not in a comma-separated list (val1,val2,..)\n window.Parsley\n .addValidator('notIn', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n var possibles = parameter.split(',');\n\n return possibles.indexOf(value) == -1;\n },\n messages: {\n en: 'The value should not be one of the following: \"%s\".'\n }\n });\n\n // Valid date formats\n window.Parsley.options.dateFormats = ['DD/MM/YY', 'DD/MM/YYYY', 'MM/DD/YY', 'MM/DD/YYYY', 'YY/MM/DD', 'YYYY/MM/DD'];\n\n // Check if the value is a date\n window.Parsley\n .addValidator('date', {\n requirementType: 'boolean',\n validateString: function (value, state, parsleyInstance) {\n return moment(value, formatDatePhpToJs.getDateFormatsOption(parsleyInstance), true).isValid();\n },\n messages: {\n en: 'You should provide a valid date.'\n }\n });\n\n\n // Check if the value is a date in a specific format\n window.Parsley\n .addValidator('dateFormat', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n return moment(value, formatDatePhpToJs.convert(parameter), true).isValid();\n },\n messages: {\n en: 'The date you entered is not in the right format (%s).'\n }\n });\n\n\n // Check if the value is a date before the specified date\n window.Parsley\n .addValidator('before', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n\n var beforeDate = moment(parameter, dateFormats, true);\n\n // If it's not a valid date, error\n if (beforeDate === false)\n return false;\n\n return moment(value, dateFormats) < beforeDate;\n },\n messages: {\n en: 'The date you entered should be before %s.'\n }\n });\n\n // Check if the value is a date before the specified date (from another input)\n window.Parsley\n .addValidator('beforeInput', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var beforeInput = jQuery(parameter);\n\n // If we can't find the input, return true\n if (beforeInput.length == 0)\n return true;\n\n var beforeVal = beforeInput.val();\n\n // If the val is empty, return true\n if (beforeVal == '')\n return true;\n\n var beforeDate = moment(beforeVal, dateFormats, true);\n\n // If the before date isn't valid, error out\n if (beforeDate.isValid() === false) {\n console.warn(parameter + ' input does not contain a valid date');\n return false;\n }\n\n var thisDate = moment(value, dateFormats, true);\n\n // If the value's date isn't valid, error out\n if (thisDate.isValid() === false) {\n console.warn('the input being checked does not contain a valid date');\n return false;\n }\n\n return thisDate < beforeDate;\n },\n messages: {\n en: 'The date you entered should be before %s.'\n }\n });\n\n\n // Check if the value is a date before the specified date\n window.Parsley\n .addValidator('after', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var afterDate = moment(parameter, dateFormats, true);\n\n // If it's not a valid date, error\n if (afterDate === false)\n return false;\n\n return moment(value, dateFormats) > afterDate;\n },\n messages: {\n en: 'The date you entered should be after %s.'\n }\n });\n\n // Check if the value is a date before the specified date (from another input)\n window.Parsley\n .addValidator('afterInput', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var afterInput = jQuery(parameter);\n\n console.log(this, dateFormats);\n\n // If we can't find the input, return true\n if (afterInput.length == 0)\n return true;\n\n var afterVal = afterInput.val();\n\n // If the val is empty, return true\n if (afterVal == '')\n return true;\n\n var afterDate = moment(afterVal, dateFormats, true);\n\n // If the after date isn't valid, error out\n if (afterDate.isValid() === false) {\n console.warn(parameter + ' input does not contain a valid date');\n return false;\n }\n\n var thisDate = moment(value, dateFormats, true);\n\n // If the value's date isn't valid, error out\n if (thisDate.isValid() === false) {\n console.warn('the input being checked does not contain a valid date');\n return false;\n }\n\n return thisDate > afterDate;\n },\n messages: {\n en: 'The date you entered should be after %s.'\n }\n });\n\n // convert PHP date format to moment JS date format\n var formatDatePhpToJs = window.formatDatePhpToJs = {\n mapChars: {\n d: 'DD',\n D: 'ddd',\n j: 'D',\n l: 'dddd',\n N: 'E',\n S: function () {\n return '[' + this.format('Do', true).replace(/\\d*/g, '') + ']';\n },\n w: 'd',\n z: function () {\n return this.format('DDD', true) - 1;\n },\n W: 'W',\n F: 'MMMM',\n m: 'MM',\n M: 'MMM',\n n: 'M',\n t: function () {\n return this.daysInMonth();\n },\n L: function () {\n return this.isLeapYear() ? 1 : 0;\n },\n o: 'GGGG',\n Y: 'YYYY',\n y: 'YY',\n a: 'a',\n A: 'A',\n B: function () {\n var thisUTC = this.clone().utc(),\n // Shamelessly stolen from http://javascript.about.com/library/blswatch.htm\n swatch = ((thisUTC.hours() + 1) % 24) + (thisUTC.minutes() / 60) + (thisUTC.seconds() / 3600);\n return Math.floor(swatch * 1000 / 24);\n },\n g: 'h',\n G: 'H',\n h: 'hh',\n H: 'HH',\n i: 'mm',\n s: 'ss',\n u: '[u]', // not sure if moment has this\n e: '[e]', // moment does not have this\n I: function () {\n return this.isDST() ? 1 : 0;\n },\n O: 'ZZ',\n P: 'Z',\n T: '[T]', // deprecated in moment\n Z: function () {\n return parseInt(this.format('ZZ', true), 10) * 36;\n },\n c: 'YYYY-MM-DD[T]HH:mm:ssZ',\n r: 'ddd, DD MMM YYYY HH:mm:ss ZZ',\n U: 'X'\n },\n formatEx: /[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g,\n convert: function (PHPDateFormat) {\n return PHPDateFormat.replace(this.formatEx, function (phpStr) {\n console.log(formatDatePhpToJs.mapChars[phpStr]);\n return typeof formatDatePhpToJs.mapChars[phpStr] === 'function' ? formatDatePhpToJs.mapChars[phpStr].call(moment()) : formatDatePhpToJs.mapChars[phpStr];\n })\n },\n getDateFormatsOption: function (parsleyInstance) {\n if (typeof parsleyInstance.options.dateFormats == 'undefined') {\n return this.getDateFormatsOption(parsleyInstance.parent);\n }\n\n return parsleyInstance.options.dateFormats;\n }\n }\n\n /**\n * Helper functions.\n *\n * @type {{parseArrayStringParameter: larapars.parseArrayStringParameter, bindChangeToOtherElement: larapars.bindChangeToOtherElement, getDateFormatsOption: larapars.getDateFormatsOption}}\n */\n var utils = {\n parseArrayStringParameter: function (parameter) {\n var m = parameter.match(/^\\s*\\[(.*)\\]\\s*$/);\n\n if (!m)\n throw 'Requirement is not an array: \"' + parameter + '\"';\n\n return m[1].replace(/\\'+/g, '').split(',');\n },\n /**\n * This is used by various validation rules that rely on another input for validation.\n *\n * This function adds a 'change' event listener which forces the original to be validated again.\n *\n * @param rule Name of the rule this change handler is for\n * @param element Which element to bind this to\n * @param fieldInstance The ParsleyFieldInstance we can call validate() on\n * @param originalNotEmpty Should the original element not be empty? (optional, default false)\n */\n bindChangeToOtherElement: function (rule, element, fieldInstance, originalNotEmpty) {\n var $elem = jQuery(element);\n var elData = $elem.data('larapars-rules');\n\n // None were added yet, initialise\n if (elData === undefined) {\n elData = [rule];\n $elem.data('larapars-rules', elData);\n }\n // Initialised, but not present\n else if (elData.indexOf(rule) == -1) {\n elData.push(rule);\n $elem.data('larapars-rules', elData);\n }\n // Already bound\n else {\n return;\n }\n\n // If not yet bound\n $elem.on('change', function () {\n if (originalNotEmpty === true && jQuery(fieldInstance.$element.get(0)).val() != '') {\n fieldInstance.validate();\n }\n else if (originalNotEmpty !== true) {\n fieldInstance.validate();\n }\n });\n }\n };\n\n // Check if the value is different from the specified input's value\n window.Parsley\n .addValidator('different', {\n requirementType: 'string',\n validateString: function (value, parameter, fieldInstance) {\n if (jQuery(parameter).length == 0)\n return true;\n\n utils.bindChangeToOtherElement('different', parameter, fieldInstance, true);\n\n return jQuery(parameter).val() != value;\n },\n messages: {\n en: 'The value should not be the same as \"%s\".'\n }\n });\n\n // Check if the value is greater than min and smaller than max\n window.Parsley\n .addValidator('between', {\n requirementType: ['integer', 'integer'],\n validateNumber: function (value, min, max) {\n return value > min && value < max;\n },\n messages: {\n en: 'The value should be between \"%s\" and \"%s\".'\n }\n });\n\n // Check if the value is equal to the provided value\n window.Parsley\n .addValidator('sizeNumber', {\n requirementType: 'integer',\n validateNumber: function (value, parameter) {\n return value == parameter;\n },\n messages: {\n en: 'The value should be \"%s\".'\n }\n });\n\n // Check if the value's length is equal to the provided value\n window.Parsley\n .addValidator('sizeString', {\n requirementType: 'integer',\n validateString: function (value, parameter) {\n return value.length == parameter;\n },\n messages: {\n en: 'The value should be \"%s\" characters long.'\n }\n });\n\n\n\n // Check if each value is distinct\n window.Parsley\n .addValidator('distinct', {\n requirementType: 'boolean',\n validateMultiple: function (values) {\n var storedValues = [];\n var isDistinct = true;\n\n values.forEach(function (value) {\n if (storedValues.indexOf(value) > -1) {\n isDistinct = false;\n return false;\n }\n\n storedValues.push(value);\n });\n\n return isDistinct;\n },\n messages: {\n en: 'Not all values are distinct.'\n }\n });\n\n\n\n // The value should be located in one of the checkbox's checked values\n window.Parsley\n .addValidator('inArray', {\n requirementType: 'string',\n validateString: function (value, otherFieldName, parsleyInstance) {\n var thisElement = jQuery(parsleyInstance.$element.get(0));\n\n var values = [];\n\n // Check if we're dealing with a text field\n if (otherFieldName.substring(0, 1) == '#') {\n // Bind a change event\n utils.bindChangeToOtherElement('inArray', otherFieldName, parsleyInstance, true);\n\n // If it's a text field we're assuming that it's a list of comma separated values\n return jQuery(otherFieldName).val().split(',').indexOf(value) > -1;\n }\n\n // Bind a change handler to the checkboxes\n jQuery('input:checkbox[name=\"' + otherFieldName + '\"]').each(function () {\n utils.bindChangeToOtherElement('inArray', this, parsleyInstance, true);\n });\n\n // Get the selected values of a checkbox by it's name\n jQuery('input:checkbox[name=\"' + otherFieldName + '\"]:checked').each(function () {\n values.push(jQuery(this).val());\n });\n\n // Check if the value is in there\n return values.indexOf(value) > -1;\n },\n messages: {\n en: 'This value is incorrect.'\n }\n });\n\n // The value is required only if another input's value matched one of the defined ones.\n // the parameter should be formatted as data-parsley-required-if=\"[\"#elementValueToCheck\", \"value1,value2,..\"]\"\n window.Parsley\n .addValidator('requiredIf', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var values = utils.parseArrayStringParameter(parameters);\n\n // Get the other input's selector\n var field = values[0];\n\n // Get the values it should contain to mark this one as required\n parameters = values.slice(1);\n\n // make sure that the other element get's a change event\n utils.bindChangeToOtherElement('requiredIf', field, fieldInstance);\n\n // Only required to check if the value is empty\n if (value.length == 0) {\n var fieldValue = jQuery(field).val();\n\n return parameters.indexOf(fieldValue) == -1;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n // The value is required if other field does not contain any of the specified values\n // the parameter should be formatted as data-parsley-required-unless=\"[\"#elementValueToCheck\", \"value1,value2,..\"]\"\n window.Parsley\n .addValidator('requiredUnless', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var values = utils.parseArrayStringParameter(parameters);\n\n // Get the other input's selector\n var field = values[0];\n\n // Get the values it should contain to mark this one as required\n parameters = values.slice(1);\n\n // make sure that the other element get's a change event\n utils.bindChangeToOtherElement('requiredUnless', field, fieldInstance);\n\n // Only required to check if the value is empty\n if (value.length == 0) {\n\n var fieldValue = jQuery(field).val();\n\n // It's not required if the input has one of the values\n return parameters.indexOf(fieldValue) > -1;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n // The value is required if any of the inputs are present in the dom\n // the parameter should be formatted as data-parsley-required-with=\"#elementValueToCheck,#elementValueToCheck,..\"\n window.Parsley\n .addValidator('requiredWith', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AnyPresent = false;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWith', id, fieldInstance);\n\n // If the element is in the dom and has a value\n if ($elem.length > 0 && $elem.val() != '') {\n AnyPresent = true;\n }\n });\n\n return !AnyPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n // The value is required if all other inputs are present in the dom\n // the parameter should be formatted as data-parsley-required-with-all=\"#elementValueToCheck,#elementValueToCheck,..\"\n window.Parsley\n .addValidator('requiredWithAll', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AllPresent = true;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n // If the value isn't in the dom or is empty\n if ($elem.length == 0 || $elem.val() == '') {\n AllPresent = false;\n }\n });\n\n return !AllPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n // The value is required if any of the inputs are not present in the dom\n // the parameter should be formatted as data-parsley-required-with=\"#elementValueToCheck,#elementValueToCheck,..\"\n window.Parsley\n .addValidator('requiredWithout', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AnyPresent = false;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n if ($elem.length == 0 || $elem.val() == '') {\n AnyPresent = true;\n }\n });\n\n return AnyPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n // The value is required if all other inputs are not present in the dom\n // the parameter should be formatted as data-parsley-required-with-all=\"#elementValueToCheck,#elementValueToCheck,..\"\n window.Parsley\n .addValidator('requiredWithoutAll', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AllEmpty = true;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n if ($elem.length == 1 && $elem.val() != '') {\n AllEmpty = false;\n }\n });\n\n return AllEmpty;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n var filesSizes = {\n b: 1,\n kb: 1024,\n mb: 1024 * 1024,\n gb: 1024 * 1024 * 1024,\n };\n\n // Make sure all files within the inputs are equal to or smaller than the defined size.\n window.Parsley\n .addValidator('fileSizeMax', {\n requirementType: ['integer', 'string'],\n validateString: function (value, maxSize, sizeMultiplyer, parsleyFieldInstance) {\n sizeMultiplyer = sizeMultiplyer.toLowerCase();\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the max file size\n maxSize = maxSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n console.log(maxSize);\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n console.log(files[i].size);\n if (files[i].size > maxSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) are too big.'\n }\n });\n\n\n // Make sure all files within the inputs are equal to or bigger than the defined size.\n window.Parsley\n .addValidator('fileSizeMin', {\n requirementType: ['integer', 'string'],\n validateString: function (value, minSize, sizeMultiplyer, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the min file size\n minSize = minSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (files[i].size < minSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) should are too small.'\n }\n });\n\n\n // Make sure all files within the inputs are between the defined sizes.\n window.Parsley\n .addValidator('fileSizeBetween', {\n requirementType: ['integer', 'integer', 'string'],\n validateString: function (value, minSize, maxSize, sizeMultiplyer, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the file sizes\n minSize = minSize * filesSizes[sizeMultiplyer.toLowerCase()];\n maxSize = maxSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (files[i].size <= minSize || files[i].size >= maxSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) should be between %s and %s %s.'\n }\n });\n\n\n // Make sure all files within the input are an image\n window.Parsley\n .addValidator('image', {\n validateString: function (value, param, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (!files[i].type.match('image/*')) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'This is not an image.'\n }\n });\n\n\n // Make sure all files within the input are an image\n window.Parsley\n .addValidator('fileMimetype', {\n requirementType: 'string',\n validateString: function (value, mimetypes, parsleyFieldInstance) {\n var allMimes = utils.parseArrayStringParameter(mimetypes);\n\n var files = parsleyFieldInstance.$element[0].files;\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (allMimes.indexOf(files[i].type) == -1) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'This file does not have the correct mimetype \"%s\".'\n }\n });\n\n // Make sure all images withing the input have specific dimensions\n\n //Parsley.addAsyncValidator();\n\n\n window.Parsley\n .addValidator('dimensions', {\n requirementType: {\n '': 'boolean',\n min_width: 'number', // Specify the minimum width the image should have\n max_width: 'number', // Specify the maximum width the image should have\n min_height: 'number', // Specify the minimum height the image should have\n max_height: 'number', // Specify the maximum height the image should have\n width: 'number', // Specify the width the image should have\n height: 'number', // Specify the height the image should have\n ratio: 'string', // Specify the ratio the image should have\n },\n validateString: function (value, param, options, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n\n // If a file is present in the input\n if (files.length > 0) {\n var defer = jQuery.Deferred();\n\n var file = new FileReader;\n\n // Set up the image validation when the file is loaded\n file.onload = function () {\n var image = new Image;\n\n // Validate once t he image is loaded\n image.onload = function () {\n var width = this.width;\n var height = this.height;\n\n // Check min width, if defined\n if (typeof options.min_width != 'undefined') {\n console.log(width, options.min_width);\n if (width < options.min_width) {\n defer.reject();\n return;\n }\n }\n\n // Check max width, if defined\n if (typeof options.max_width != 'undefined') {\n if (width > options.max_width) {\n defer.reject();\n return;\n }\n }\n\n // Check min height, if defined\n if (typeof options.min_height != 'undefined') {\n if (height < options.min_height) {\n defer.reject();\n return;\n }\n }\n\n // Check max height, if defined\n if (typeof options.max_height != 'undefined') {\n if (height > options.max_height) {\n defer.reject();\n return;\n }\n }\n\n // Check width, if defined\n if (typeof options.width != 'undefined') {\n if (width != options.width) {\n defer.reject();\n return;\n }\n }\n\n // Check height, if defined\n if (typeof options.height != 'undefined') {\n if (height != options.height) {\n defer.reject();\n return;\n }\n }\n\n // Check ratio, if defined\n if (typeof options.ratio != 'undefined') {\n var splitRatio = options.ratio.split(':');\n\n if (splitRatio[0] / splitRatio[1] != width / height) {\n defer.reject();\n return;\n }\n }\n\n defer.resolve();\n };\n\n // On error, reject the promise\n image.onerror = function() {\n console.log('image error');\n defer.reject();\n }\n\n // Set the image\n console.log(file.result);\n image.src = file.result;\n }\n\n // On error, reject the promise\n file.onerror = function() {\n console.log('file error');\n defer.reject();\n }\n\n // Set the file\n console.log(files[0]);\n file.readAsDataURL(files[0])\n\n return defer.promise();\n }\n\n return true;\n }\n });\n\n /**\n * Overwrite core Parsley methods.\n *\n * @type {{_isRequired: Window.ParsleyExtend._isRequired}}\n */\n window.ParsleyExtend = {\n // Normally this was intended Internal only.\n // Field is required if have required constraint without `false` value\n _isRequired: function () {\n\n var requiredRules = [\n // This one comes out of the box with parsley\n 'required',\n\n // These ones were added with this library\n 'requiredIf', 'requiredUnless', 'requiredWith', 'requiredWithAll', 'requiredWithout', 'requiredWithoutAll'\n ];\n\n var requiredRulesFound = [];\n\n // Loop over the list to check if they're defined on the field.\n requiredRules.forEach(function (rule) {\n if ('undefined' !== typeof this.constraintsByName[rule]) {\n requiredRulesFound.push(rule);\n }\n }, this);\n\n // If there's not one required rule, return false\n if (requiredRulesFound.length == 0)\n return false;\n\n // If parsley's on required rule was found\n if (requiredRulesFound.indexOf('required') >= 0) {\n // Check if the flag is set to true\n return false !== this.constraintsByName.required.requirements;\n }\n\n return true;\n }\n };\n\n var main = utils;\n\n return main;\n\n}));\n","// Check if the value is within a comma-separated list (val1,val2,..)\nwindow.Parsley\n .addValidator('in', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n var possibles = parameter.split(',');\n\n return possibles.indexOf(value) > -1;\n },\n messages: {\n en: 'The value should be one of the following: \"%s\".'\n }\n });\n\n// Check if the value is not in a comma-separated list (val1,val2,..)\nwindow.Parsley\n .addValidator('notIn', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n var possibles = parameter.split(',');\n\n return possibles.indexOf(value) == -1;\n },\n messages: {\n en: 'The value should not be one of the following: \"%s\".'\n }\n });","import moment from 'moment';\nimport jQuery from 'jquery';\n\n// Valid date formats\nwindow.Parsley.options.dateFormats = ['DD/MM/YY', 'DD/MM/YYYY', 'MM/DD/YY', 'MM/DD/YYYY', 'YY/MM/DD', 'YYYY/MM/DD'];\n\n// Check if the value is a date\nwindow.Parsley\n .addValidator('date', {\n requirementType: 'boolean',\n validateString: function (value, state, parsleyInstance) {\n return moment(value, formatDatePhpToJs.getDateFormatsOption(parsleyInstance), true).isValid();\n },\n messages: {\n en: 'You should provide a valid date.'\n }\n });\n\n\n// Check if the value is a date in a specific format\nwindow.Parsley\n .addValidator('dateFormat', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n return moment(value, formatDatePhpToJs.convert(parameter), true).isValid();\n },\n messages: {\n en: 'The date you entered is not in the right format (%s).'\n }\n });\n\n\n// Check if the value is a date before the specified date\nwindow.Parsley\n .addValidator('before', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n\n var beforeDate = moment(parameter, dateFormats, true);\n\n // If it's not a valid date, error\n if (beforeDate === false)\n return false;\n\n return moment(value, dateFormats) < beforeDate;\n },\n messages: {\n en: 'The date you entered should be before %s.'\n }\n });\n\n// Check if the value is a date before the specified date (from another input)\nwindow.Parsley\n .addValidator('beforeInput', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var beforeInput = jQuery(parameter);\n\n // If we can't find the input, return true\n if (beforeInput.length == 0)\n return true;\n\n var beforeVal = beforeInput.val();\n\n // If the val is empty, return true\n if (beforeVal == '')\n return true;\n\n var beforeDate = moment(beforeVal, dateFormats, true);\n\n // If the before date isn't valid, error out\n if (beforeDate.isValid() === false) {\n console.warn(parameter + ' input does not contain a valid date');\n return false;\n }\n\n var thisDate = moment(value, dateFormats, true);\n\n // If the value's date isn't valid, error out\n if (thisDate.isValid() === false) {\n console.warn('the input being checked does not contain a valid date');\n return false;\n }\n\n return thisDate < beforeDate;\n },\n messages: {\n en: 'The date you entered should be before %s.'\n }\n });\n\n\n// Check if the value is a date before the specified date\nwindow.Parsley\n .addValidator('after', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var afterDate = moment(parameter, dateFormats, true);\n\n // If it's not a valid date, error\n if (afterDate === false)\n return false;\n\n return moment(value, dateFormats) > afterDate;\n },\n messages: {\n en: 'The date you entered should be after %s.'\n }\n });\n\n// Check if the value is a date before the specified date (from another input)\nwindow.Parsley\n .addValidator('afterInput', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var afterInput = jQuery(parameter);\n\n console.log(this, dateFormats);\n\n // If we can't find the input, return true\n if (afterInput.length == 0)\n return true;\n\n var afterVal = afterInput.val();\n\n // If the val is empty, return true\n if (afterVal == '')\n return true;\n\n var afterDate = moment(afterVal, dateFormats, true);\n\n // If the after date isn't valid, error out\n if (afterDate.isValid() === false) {\n console.warn(parameter + ' input does not contain a valid date');\n return false;\n }\n\n var thisDate = moment(value, dateFormats, true);\n\n // If the value's date isn't valid, error out\n if (thisDate.isValid() === false) {\n console.warn('the input being checked does not contain a valid date');\n return false;\n }\n\n return thisDate > afterDate;\n },\n messages: {\n en: 'The date you entered should be after %s.'\n }\n });\n\n// convert PHP date format to moment JS date format\nvar formatDatePhpToJs = window.formatDatePhpToJs = {\n mapChars: {\n d: 'DD',\n D: 'ddd',\n j: 'D',\n l: 'dddd',\n N: 'E',\n S: function () {\n return '[' + this.format('Do', true).replace(/\\d*/g, '') + ']';\n },\n w: 'd',\n z: function () {\n return this.format('DDD', true) - 1;\n },\n W: 'W',\n F: 'MMMM',\n m: 'MM',\n M: 'MMM',\n n: 'M',\n t: function () {\n return this.daysInMonth();\n },\n L: function () {\n return this.isLeapYear() ? 1 : 0;\n },\n o: 'GGGG',\n Y: 'YYYY',\n y: 'YY',\n a: 'a',\n A: 'A',\n B: function () {\n var thisUTC = this.clone().utc(),\n // Shamelessly stolen from http://javascript.about.com/library/blswatch.htm\n swatch = ((thisUTC.hours() + 1) % 24) + (thisUTC.minutes() / 60) + (thisUTC.seconds() / 3600);\n return Math.floor(swatch * 1000 / 24);\n },\n g: 'h',\n G: 'H',\n h: 'hh',\n H: 'HH',\n i: 'mm',\n s: 'ss',\n u: '[u]', // not sure if moment has this\n e: '[e]', // moment does not have this\n I: function () {\n return this.isDST() ? 1 : 0;\n },\n O: 'ZZ',\n P: 'Z',\n T: '[T]', // deprecated in moment\n Z: function () {\n return parseInt(this.format('ZZ', true), 10) * 36;\n },\n c: 'YYYY-MM-DD[T]HH:mm:ssZ',\n r: 'ddd, DD MMM YYYY HH:mm:ss ZZ',\n U: 'X'\n },\n formatEx: /[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g,\n convert: function (PHPDateFormat) {\n return PHPDateFormat.replace(this.formatEx, function (phpStr) {\n console.log(formatDatePhpToJs.mapChars[phpStr]);\n return typeof formatDatePhpToJs.mapChars[phpStr] === 'function' ? formatDatePhpToJs.mapChars[phpStr].call(moment()) : formatDatePhpToJs.mapChars[phpStr];\n })\n },\n getDateFormatsOption: function (parsleyInstance) {\n if (typeof parsleyInstance.options.dateFormats == 'undefined') {\n return this.getDateFormatsOption(parsleyInstance.parent);\n }\n\n return parsleyInstance.options.dateFormats;\n }\n}","import jQuery from 'jquery';\n\n/**\n * Helper functions.\n *\n * @type {{parseArrayStringParameter: larapars.parseArrayStringParameter, bindChangeToOtherElement: larapars.bindChangeToOtherElement, getDateFormatsOption: larapars.getDateFormatsOption}}\n */\nexport default {\n parseArrayStringParameter: function (parameter) {\n var m = parameter.match(/^\\s*\\[(.*)\\]\\s*$/);\n\n if (!m)\n throw 'Requirement is not an array: \"' + parameter + '\"';\n\n return m[1].replace(/\\'+/g, '').split(',');\n },\n /**\n * This is used by various validation rules that rely on another input for validation.\n *\n * This function adds a 'change' event listener which forces the original to be validated again.\n *\n * @param rule Name of the rule this change handler is for\n * @param element Which element to bind this to\n * @param fieldInstance The ParsleyFieldInstance we can call validate() on\n * @param originalNotEmpty Should the original element not be empty? (optional, default false)\n */\n bindChangeToOtherElement: function (rule, element, fieldInstance, originalNotEmpty) {\n var $elem = jQuery(element);\n var elData = $elem.data('larapars-rules');\n\n // None were added yet, initialise\n if (elData === undefined) {\n elData = [rule];\n $elem.data('larapars-rules', elData);\n }\n // Initialised, but not present\n else if (elData.indexOf(rule) == -1) {\n elData.push(rule);\n $elem.data('larapars-rules', elData);\n }\n // Already bound\n else {\n return;\n }\n\n // If not yet bound\n $elem.on('change', function () {\n if (originalNotEmpty === true && jQuery(fieldInstance.$element.get(0)).val() != '') {\n fieldInstance.validate();\n }\n else if (originalNotEmpty !== true) {\n fieldInstance.validate();\n }\n });\n }\n};","import jQuery from 'jquery';\nimport utils from '../utils.js';\n\n// Check if the value is different from the specified input's value\nwindow.Parsley\n .addValidator('different', {\n requirementType: 'string',\n validateString: function (value, parameter, fieldInstance) {\n if (jQuery(parameter).length == 0)\n return true;\n\n utils.bindChangeToOtherElement('different', parameter, fieldInstance, true);\n\n return jQuery(parameter).val() != value;\n },\n messages: {\n en: 'The value should not be the same as \"%s\".'\n }\n });\n\n// Check if the value is greater than min and smaller than max\nwindow.Parsley\n .addValidator('between', {\n requirementType: ['integer', 'integer'],\n validateNumber: function (value, min, max) {\n return value > min && value < max;\n },\n messages: {\n en: 'The value should be between \"%s\" and \"%s\".'\n }\n });\n\n// Check if the value is equal to the provided value\nwindow.Parsley\n .addValidator('sizeNumber', {\n requirementType: 'integer',\n validateNumber: function (value, parameter) {\n return value == parameter;\n },\n messages: {\n en: 'The value should be \"%s\".'\n }\n });\n\n// Check if the value's length is equal to the provided value\nwindow.Parsley\n .addValidator('sizeString', {\n requirementType: 'integer',\n validateString: function (value, parameter) {\n return value.length == parameter;\n },\n messages: {\n en: 'The value should be \"%s\" characters long.'\n }\n });\n\n\n\n// Check if each value is distinct\nwindow.Parsley\n .addValidator('distinct', {\n requirementType: 'boolean',\n validateMultiple: function (values) {\n var storedValues = [];\n var isDistinct = true;\n\n values.forEach(function (value) {\n if (storedValues.indexOf(value) > -1) {\n isDistinct = false;\n return false;\n }\n\n storedValues.push(value);\n });\n\n return isDistinct;\n },\n messages: {\n en: 'Not all values are distinct.'\n }\n });\n\n\n\n// The value should be located in one of the checkbox's checked values\nwindow.Parsley\n .addValidator('inArray', {\n requirementType: 'string',\n validateString: function (value, otherFieldName, parsleyInstance) {\n var thisElement = jQuery(parsleyInstance.$element.get(0));\n\n var values = [];\n\n // Check if we're dealing with a text field\n if (otherFieldName.substring(0, 1) == '#') {\n // Bind a change event\n utils.bindChangeToOtherElement('inArray', otherFieldName, parsleyInstance, true);\n\n // If it's a text field we're assuming that it's a list of comma separated values\n return jQuery(otherFieldName).val().split(',').indexOf(value) > -1;\n }\n\n // Bind a change handler to the checkboxes\n jQuery('input:checkbox[name=\"' + otherFieldName + '\"]').each(function () {\n utils.bindChangeToOtherElement('inArray', this, parsleyInstance, true);\n });\n\n // Get the selected values of a checkbox by it's name\n jQuery('input:checkbox[name=\"' + otherFieldName + '\"]:checked').each(function () {\n values.push(jQuery(this).val());\n });\n\n // Check if the value is in there\n return values.indexOf(value) > -1;\n },\n messages: {\n en: 'This value is incorrect.'\n }\n });","import jQuery from 'jquery';\nimport utils from '../utils.js';\n\n// The value is required only if another input's value matched one of the defined ones.\n// the parameter should be formatted as data-parsley-required-if=\"[\"#elementValueToCheck\", \"value1,value2,..\"]\"\nwindow.Parsley\n .addValidator('requiredIf', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var values = utils.parseArrayStringParameter(parameters);\n\n // Get the other input's selector\n var field = values[0];\n\n // Get the values it should contain to mark this one as required\n parameters = values.slice(1);\n\n // make sure that the other element get's a change event\n utils.bindChangeToOtherElement('requiredIf', field, fieldInstance);\n\n // Only required to check if the value is empty\n if (value.length == 0) {\n var fieldValue = jQuery(field).val();\n\n return parameters.indexOf(fieldValue) == -1;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n// The value is required if other field does not contain any of the specified values\n// the parameter should be formatted as data-parsley-required-unless=\"[\"#elementValueToCheck\", \"value1,value2,..\"]\"\nwindow.Parsley\n .addValidator('requiredUnless', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var values = utils.parseArrayStringParameter(parameters);\n\n // Get the other input's selector\n var field = values[0];\n\n // Get the values it should contain to mark this one as required\n parameters = values.slice(1);\n\n // make sure that the other element get's a change event\n utils.bindChangeToOtherElement('requiredUnless', field, fieldInstance);\n\n // Only required to check if the value is empty\n if (value.length == 0) {\n\n var fieldValue = jQuery(field).val();\n\n // It's not required if the input has one of the values\n return parameters.indexOf(fieldValue) > -1;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n// The value is required if any of the inputs are present in the dom\n// the parameter should be formatted as data-parsley-required-with=\"#elementValueToCheck,#elementValueToCheck,..\"\nwindow.Parsley\n .addValidator('requiredWith', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AnyPresent = false;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWith', id, fieldInstance);\n\n // If the element is in the dom and has a value\n if ($elem.length > 0 && $elem.val() != '') {\n AnyPresent = true;\n }\n });\n\n return !AnyPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n// The value is required if all other inputs are present in the dom\n// the parameter should be formatted as data-parsley-required-with-all=\"#elementValueToCheck,#elementValueToCheck,..\"\nwindow.Parsley\n .addValidator('requiredWithAll', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AllPresent = true;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n // If the value isn't in the dom or is empty\n if ($elem.length == 0 || $elem.val() == '') {\n AllPresent = false;\n }\n });\n\n return !AllPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n// The value is required if any of the inputs are not present in the dom\n// the parameter should be formatted as data-parsley-required-with=\"#elementValueToCheck,#elementValueToCheck,..\"\nwindow.Parsley\n .addValidator('requiredWithout', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AnyPresent = false;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n if ($elem.length == 0 || $elem.val() == '') {\n AnyPresent = true;\n }\n });\n\n return AnyPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n// The value is required if all other inputs are not present in the dom\n// the parameter should be formatted as data-parsley-required-with-all=\"#elementValueToCheck,#elementValueToCheck,..\"\nwindow.Parsley\n .addValidator('requiredWithoutAll', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AllEmpty = true;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n if ($elem.length == 1 && $elem.val() != '') {\n AllEmpty = false;\n }\n });\n\n return AllEmpty;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });","import jQuery from 'jquery';\nimport utils from '../utils.js';\n\nvar filesSizes = {\n b: 1,\n kb: 1024,\n mb: 1024 * 1024,\n gb: 1024 * 1024 * 1024,\n};\n\n// Make sure all files within the inputs are equal to or smaller than the defined size.\nwindow.Parsley\n .addValidator('fileSizeMax', {\n requirementType: ['integer', 'string'],\n validateString: function (value, maxSize, sizeMultiplyer, parsleyFieldInstance) {\n sizeMultiplyer = sizeMultiplyer.toLowerCase();\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the max file size\n maxSize = maxSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n console.log(maxSize);\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n console.log(files[i].size);\n if (files[i].size > maxSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) are too big.'\n }\n });\n\n\n// Make sure all files within the inputs are equal to or bigger than the defined size.\nwindow.Parsley\n .addValidator('fileSizeMin', {\n requirementType: ['integer', 'string'],\n validateString: function (value, minSize, sizeMultiplyer, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the min file size\n minSize = minSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (files[i].size < minSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) should are too small.'\n }\n });\n\n\n// Make sure all files within the inputs are between the defined sizes.\nwindow.Parsley\n .addValidator('fileSizeBetween', {\n requirementType: ['integer', 'integer', 'string'],\n validateString: function (value, minSize, maxSize, sizeMultiplyer, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the file sizes\n minSize = minSize * filesSizes[sizeMultiplyer.toLowerCase()];\n maxSize = maxSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (files[i].size <= minSize || files[i].size >= maxSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) should be between %s and %s %s.'\n }\n });\n\n\n// Make sure all files within the input are an image\nwindow.Parsley\n .addValidator('image', {\n validateString: function (value, param, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (!files[i].type.match('image/*')) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'This is not an image.'\n }\n });\n\n\n// Make sure all files within the input are an image\nwindow.Parsley\n .addValidator('fileMimetype', {\n requirementType: 'string',\n validateString: function (value, mimetypes, parsleyFieldInstance) {\n var allMimes = utils.parseArrayStringParameter(mimetypes);\n\n var files = parsleyFieldInstance.$element[0].files;\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (allMimes.indexOf(files[i].type) == -1) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'This file does not have the correct mimetype \"%s\".'\n }\n });\n\n// Make sure all images withing the input have specific dimensions\n\n//Parsley.addAsyncValidator();\n\n\nwindow.Parsley\n .addValidator('dimensions', {\n requirementType: {\n '': 'boolean',\n min_width: 'number', // Specify the minimum width the image should have\n max_width: 'number', // Specify the maximum width the image should have\n min_height: 'number', // Specify the minimum height the image should have\n max_height: 'number', // Specify the maximum height the image should have\n width: 'number', // Specify the width the image should have\n height: 'number', // Specify the height the image should have\n ratio: 'string', // Specify the ratio the image should have\n },\n validateString: function (value, param, options, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n\n // If a file is present in the input\n if (files.length > 0) {\n var defer = jQuery.Deferred();\n\n var file = new FileReader;\n\n // Set up the image validation when the file is loaded\n file.onload = function () {\n var image = new Image;\n\n // Validate once t he image is loaded\n image.onload = function () {\n var width = this.width;\n var height = this.height;\n\n // Check min width, if defined\n if (typeof options.min_width != 'undefined') {\n console.log(width, options.min_width);\n if (width < options.min_width) {\n defer.reject();\n return;\n }\n }\n\n // Check max width, if defined\n if (typeof options.max_width != 'undefined') {\n if (width > options.max_width) {\n defer.reject();\n return;\n }\n }\n\n // Check min height, if defined\n if (typeof options.min_height != 'undefined') {\n if (height < options.min_height) {\n defer.reject();\n return;\n }\n }\n\n // Check max height, if defined\n if (typeof options.max_height != 'undefined') {\n if (height > options.max_height) {\n defer.reject();\n return;\n }\n }\n\n // Check width, if defined\n if (typeof options.width != 'undefined') {\n if (width != options.width) {\n defer.reject();\n return;\n }\n }\n\n // Check height, if defined\n if (typeof options.height != 'undefined') {\n if (height != options.height) {\n defer.reject();\n return;\n }\n }\n\n // Check ratio, if defined\n if (typeof options.ratio != 'undefined') {\n var splitRatio = options.ratio.split(':');\n\n if (splitRatio[0] / splitRatio[1] != width / height) {\n defer.reject();\n return;\n }\n }\n\n defer.resolve();\n };\n\n // On error, reject the promise\n image.onerror = function() {\n console.log('image error');\n defer.reject();\n }\n\n // Set the image\n console.log(file.result);\n image.src = file.result;\n }\n\n // On error, reject the promise\n file.onerror = function() {\n console.log('file error');\n defer.reject();\n }\n\n // Set the file\n console.log(files[0]);\n file.readAsDataURL(files[0])\n\n return defer.promise();\n }\n\n return true;\n }\n });","import jQuery from 'jquery';\nimport './rules/ins';\nimport './rules/dates';\nimport './rules/comparison';\nimport './rules/requireds.js';\nimport './rules/files.js';\nimport './utils.js';\n\n/**\n * Overwrite core Parsley methods.\n *\n * @type {{_isRequired: Window.ParsleyExtend._isRequired}}\n */\nwindow.ParsleyExtend = {\n // Normally this was intended Internal only.\n // Field is required if have required constraint without `false` value\n _isRequired: function () {\n\n var requiredRules = [\n // This one comes out of the box with parsley\n 'required',\n\n // These ones were added with this library\n 'requiredIf', 'requiredUnless', 'requiredWith', 'requiredWithAll', 'requiredWithout', 'requiredWithoutAll'\n ];\n\n var requiredRulesFound = [];\n\n // Loop over the list to check if they're defined on the field.\n requiredRules.forEach(function (rule) {\n if ('undefined' !== typeof this.constraintsByName[rule]) {\n requiredRulesFound.push(rule);\n }\n }, this);\n\n // If there's not one required rule, return false\n if (requiredRulesFound.length == 0)\n return false;\n\n // If parsley's on required rule was found\n if (requiredRulesFound.indexOf('required') >= 0) {\n // Check if the flag is set to true\n return false !== this.constraintsByName.required.requirements;\n }\n\n return true;\n }\n};\n\nexport default utils;"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["laravel-parsley.js","src/rules/ins.js","src/rules/dates.js","src/utils.js","src/rules/comparison.js","src/rules/requ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,CAAA;;AAER,2BAAO,IAAA,CAAA;iBAC3B,EAAmB,UAAS,KAAA,EAAM;;AAEd,yBAAA,GAAQ,IAAA,CAAA;;AAER,2BAAO,KAAA,CAAA;iBAC3B,CAAA,CAAA;aACA;;AAEY,mBAAO,IAAA,CAAA;SACnB;KACA,CAAA,CAAA;;;;;;;ACzPA,UAAA,CAAO,aAAA,GAAgB;;;AAGnB,mBAAA,EAAa,uBAAY;;AAErB,gBAAI,aAAA,GAAgB;;AAEhB,sBAAA;;;AAGA,wBAAA,EAAc,gBAAA,EAAkB,cAAA,EAAgB,iBAAA,EAAmB,iBAAA,EAAmB,oBAAA,CAClG,CAAA;;AAEQ,gBAAI,kBAAA,GAAqB,EAAA,CAAA;;;AAGzB,yBAAA,CAAc,OAAA,CAAQ,UAAU,IAAA,EAAM;AAClC,oBAAI,WAAA,KAAgB,OAAO,IAAA,CAAK,iBAAA,CAAkB,IAAA,CAAA,EAAO;AACrD,sCAAA,CAAmB,IAAA,CAAK,IAAA,CAAA,CAAA;iBACxC;aACA,EAAW,IAAA,CAAA,CAAA;;;AAGH,gBAAI,kBAAA,CAAmB,MAAA,IAAU,CAAA,EAC7B,OAAO,KAAA,CAAA;;;AAGX,gBAAI,kBAAA,CAAmB,OAAA,CAAQ,UAAA,CAAA,IAAe,CAAA,EAAG;;AAE7C,uBAAO,KAAA,KAAU,IAAA,CAAK,iBAAA,CAAkB,QAAA,CAAS,YAAA,CAAA;aAC7D;;AAEQ,mBAAO,IAAA,CAAA;SACf;KA9CA,CAAA;;AAAA,QAAA,IAAA,GAAA,KAAA,CAAA;;APk7BI,WAAO,IAAI,CAAC;CAEf,CAAC,CAAE","file":"laravel-parsley.js","sourcesContent":["(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('moment')) :\n typeof define === 'function' && define.amd ? define(['jquery', 'moment'], factory) :\n global.laraParsley = factory(global.jQuery, global.moment)\n}(this, function (jQuery, moment) { 'use strict';\n\n // Check if the value is within a comma-separated list (val1,val2,..)\n window.Parsley\n .addValidator('in', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n var possibles = parameter.split(',');\n\n return possibles.indexOf(value) > -1;\n },\n messages: {\n en: 'The value should be one of the following: \"%s\".'\n }\n });\n\n // Check if the value is not in a comma-separated list (val1,val2,..)\n window.Parsley\n .addValidator('notIn', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n var possibles = parameter.split(',');\n\n return possibles.indexOf(value) == -1;\n },\n messages: {\n en: 'The value should not be one of the following: \"%s\".'\n }\n });\n\n // Valid date formats\n window.Parsley.options.dateFormats = ['DD/MM/YY', 'DD/MM/YYYY', 'MM/DD/YY', 'MM/DD/YYYY', 'YY/MM/DD', 'YYYY/MM/DD'];\n\n // Check if the value is a date\n window.Parsley\n .addValidator('date', {\n requirementType: 'boolean',\n validateString: function (value, state, parsleyInstance) {\n return moment(value, formatDatePhpToJs.getDateFormatsOption(parsleyInstance), true).isValid();\n },\n messages: {\n en: 'You should provide a valid date.'\n }\n });\n\n\n // Check if the value is a date in a specific format\n window.Parsley\n .addValidator('dateFormat', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n return moment(value, formatDatePhpToJs.convert(parameter), true).isValid();\n },\n messages: {\n en: 'The date you entered is not in the right format (%s).'\n }\n });\n\n\n // Check if the value is a date before the specified date\n window.Parsley\n .addValidator('before', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n\n var beforeDate = moment(parameter, dateFormats, true);\n\n // If it's not a valid date, error\n if (beforeDate === false)\n return false;\n\n return moment(value, dateFormats) < beforeDate;\n },\n messages: {\n en: 'The date you entered should be before %s.'\n }\n });\n\n // Check if the value is a date before the specified date (from another input)\n window.Parsley\n .addValidator('beforeInput', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var beforeInput = jQuery(parameter);\n\n // If we can't find the input, return true\n if (beforeInput.length == 0)\n return true;\n\n var beforeVal = beforeInput.val();\n\n // If the val is empty, return true\n if (beforeVal == '')\n return true;\n\n var beforeDate = moment(beforeVal, dateFormats, true);\n\n // If the before date isn't valid, error out\n if (beforeDate.isValid() === false) {\n console.warn(parameter + ' input does not contain a valid date');\n return false;\n }\n\n var thisDate = moment(value, dateFormats, true);\n\n // If the value's date isn't valid, error out\n if (thisDate.isValid() === false) {\n console.warn('the input being checked does not contain a valid date');\n return false;\n }\n\n return thisDate < beforeDate;\n },\n messages: {\n en: 'The date you entered should be before %s.'\n }\n });\n\n\n // Check if the value is a date before the specified date\n window.Parsley\n .addValidator('after', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var afterDate = moment(parameter, dateFormats, true);\n\n // If it's not a valid date, error\n if (afterDate === false)\n return false;\n\n return moment(value, dateFormats) > afterDate;\n },\n messages: {\n en: 'The date you entered should be after %s.'\n }\n });\n\n // Check if the value is a date before the specified date (from another input)\n window.Parsley\n .addValidator('afterInput', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var afterInput = jQuery(parameter);\n\n console.log(this, dateFormats);\n\n // If we can't find the input, return true\n if (afterInput.length == 0)\n return true;\n\n var afterVal = afterInput.val();\n\n // If the val is empty, return true\n if (afterVal == '')\n return true;\n\n var afterDate = moment(afterVal, dateFormats, true);\n\n // If the after date isn't valid, error out\n if (afterDate.isValid() === false) {\n console.warn(parameter + ' input does not contain a valid date');\n return false;\n }\n\n var thisDate = moment(value, dateFormats, true);\n\n // If the value's date isn't valid, error out\n if (thisDate.isValid() === false) {\n console.warn('the input being checked does not contain a valid date');\n return false;\n }\n\n return thisDate > afterDate;\n },\n messages: {\n en: 'The date you entered should be after %s.'\n }\n });\n\n // convert PHP date format to moment JS date format\n var formatDatePhpToJs = window.formatDatePhpToJs = {\n mapChars: {\n d: 'DD',\n D: 'ddd',\n j: 'D',\n l: 'dddd',\n N: 'E',\n S: function () {\n return '[' + this.format('Do', true).replace(/\\d*/g, '') + ']';\n },\n w: 'd',\n z: function () {\n return this.format('DDD', true) - 1;\n },\n W: 'W',\n F: 'MMMM',\n m: 'MM',\n M: 'MMM',\n n: 'M',\n t: function () {\n return this.daysInMonth();\n },\n L: function () {\n return this.isLeapYear() ? 1 : 0;\n },\n o: 'GGGG',\n Y: 'YYYY',\n y: 'YY',\n a: 'a',\n A: 'A',\n B: function () {\n var thisUTC = this.clone().utc(),\n // Shamelessly stolen from http://javascript.about.com/library/blswatch.htm\n swatch = ((thisUTC.hours() + 1) % 24) + (thisUTC.minutes() / 60) + (thisUTC.seconds() / 3600);\n return Math.floor(swatch * 1000 / 24);\n },\n g: 'h',\n G: 'H',\n h: 'hh',\n H: 'HH',\n i: 'mm',\n s: 'ss',\n u: '[u]', // not sure if moment has this\n e: '[e]', // moment does not have this\n I: function () {\n return this.isDST() ? 1 : 0;\n },\n O: 'ZZ',\n P: 'Z',\n T: '[T]', // deprecated in moment\n Z: function () {\n return parseInt(this.format('ZZ', true), 10) * 36;\n },\n c: 'YYYY-MM-DD[T]HH:mm:ssZ',\n r: 'ddd, DD MMM YYYY HH:mm:ss ZZ',\n U: 'X'\n },\n formatEx: /[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g,\n convert: function (PHPDateFormat) {\n return PHPDateFormat.replace(this.formatEx, function (phpStr) {\n console.log(formatDatePhpToJs.mapChars[phpStr]);\n return typeof formatDatePhpToJs.mapChars[phpStr] === 'function' ? formatDatePhpToJs.mapChars[phpStr].call(moment()) : formatDatePhpToJs.mapChars[phpStr];\n })\n },\n getDateFormatsOption: function (parsleyInstance) {\n if (typeof parsleyInstance.options.dateFormats == 'undefined') {\n return this.getDateFormatsOption(parsleyInstance.parent);\n }\n\n return parsleyInstance.options.dateFormats;\n }\n }\n\n /**\n * Helper functions.\n *\n * @type {{parseArrayStringParameter: larapars.parseArrayStringParameter, bindChangeToOtherElement: larapars.bindChangeToOtherElement, getDateFormatsOption: larapars.getDateFormatsOption}}\n */\n var utils = {\n parseArrayStringParameter: function (parameter) {\n var m = parameter.match(/^\\s*\\[(.*)\\]\\s*$/);\n\n if (!m)\n throw 'Requirement is not an array: \"' + parameter + '\"';\n\n return m[1].replace(/\\'+/g, '').split(',');\n },\n /**\n * This is used by various validation rules that rely on another input for validation.\n *\n * This function adds a 'change' event listener which forces the original to be validated again.\n *\n * @param rule Name of the rule this change handler is for\n * @param element Which element to bind this to\n * @param fieldInstance The ParsleyFieldInstance we can call validate() on\n * @param originalNotEmpty Should the original element not be empty? (optional, default false)\n */\n bindChangeToOtherElement: function (rule, element, fieldInstance, originalNotEmpty) {\n var $elem = jQuery(element);\n var elData = $elem.data('larapars-rules');\n\n // None were added yet, initialise\n if (elData === undefined) {\n elData = [rule];\n $elem.data('larapars-rules', elData);\n }\n // Initialised, but not present\n else if (elData.indexOf(rule) == -1) {\n elData.push(rule);\n $elem.data('larapars-rules', elData);\n }\n // Already bound\n else {\n return;\n }\n\n // If not yet bound\n $elem.on('change', function () {\n if (originalNotEmpty === true && jQuery(fieldInstance.$element.get(0)).val() != '') {\n fieldInstance.validate();\n }\n else if (originalNotEmpty !== true) {\n fieldInstance.validate();\n }\n });\n }\n };\n\n // Check if the value is different from the specified input's value\n window.Parsley\n .addValidator('different', {\n requirementType: 'string',\n validateString: function (value, parameter, fieldInstance) {\n if (jQuery(parameter).length == 0)\n return true;\n\n utils.bindChangeToOtherElement('different', parameter, fieldInstance, true);\n\n return jQuery(parameter).val() != value;\n },\n messages: {\n en: 'The value should not be the same as \"%s\".'\n }\n });\n\n // Check if the value is greater than min and smaller than max\n window.Parsley\n .addValidator('between', {\n requirementType: ['integer', 'integer'],\n validateNumber: function (value, min, max) {\n return value > min && value < max;\n },\n messages: {\n en: 'The value should be between \"%s\" and \"%s\".'\n }\n });\n\n // Check if the value is equal to the provided value\n window.Parsley\n .addValidator('sizeNumber', {\n requirementType: 'integer',\n validateNumber: function (value, parameter) {\n return value == parameter;\n },\n messages: {\n en: 'The value should be \"%s\".'\n }\n });\n\n // Check if the value's length is equal to the provided value\n window.Parsley\n .addValidator('sizeString', {\n requirementType: 'integer',\n validateString: function (value, parameter) {\n return value.length == parameter;\n },\n messages: {\n en: 'The value should be \"%s\" characters long.'\n }\n });\n\n\n\n // Check if each value is distinct\n window.Parsley\n .addValidator('distinct', {\n requirementType: 'boolean',\n validateMultiple: function (values) {\n var storedValues = [];\n var isDistinct = true;\n\n values.forEach(function (value) {\n if (storedValues.indexOf(value) > -1) {\n isDistinct = false;\n return false;\n }\n\n storedValues.push(value);\n });\n\n return isDistinct;\n },\n messages: {\n en: 'Not all values are distinct.'\n }\n });\n\n\n\n // The value should be located in one of the checkbox's checked values\n window.Parsley\n .addValidator('inArray', {\n requirementType: 'string',\n validateString: function (value, otherFieldName, parsleyInstance) {\n var thisElement = jQuery(parsleyInstance.$element.get(0));\n\n var values = [];\n\n // Check if we're dealing with a text field\n if (otherFieldName.substring(0, 1) == '#') {\n // Bind a change event\n utils.bindChangeToOtherElement('inArray', otherFieldName, parsleyInstance, true);\n\n // If it's a text field we're assuming that it's a list of comma separated values\n return jQuery(otherFieldName).val().split(',').indexOf(value) > -1;\n }\n\n // Bind a change handler to the checkboxes\n jQuery('input:checkbox[name=\"' + otherFieldName + '\"]').each(function () {\n utils.bindChangeToOtherElement('inArray', this, parsleyInstance, true);\n });\n\n // Get the selected values of a checkbox by it's name\n jQuery('input:checkbox[name=\"' + otherFieldName + '\"]:checked').each(function () {\n values.push(jQuery(this).val());\n });\n\n // Check if the value is in there\n return values.indexOf(value) > -1;\n },\n messages: {\n en: 'This value is incorrect.'\n }\n });\n\n // The value is required only if another input's value matched one of the defined ones.\n // the parameter should be formatted as data-parsley-required-if=\"[\"#elementValueToCheck\", \"value1,value2,..\"]\"\n window.Parsley\n .addValidator('requiredIf', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var values = utils.parseArrayStringParameter(parameters);\n\n // Get the other input's selector\n var field = values[0];\n\n // Get the values it should contain to mark this one as required\n parameters = values.slice(1);\n\n // make sure that the other element get's a change event\n utils.bindChangeToOtherElement('requiredIf', field, fieldInstance);\n\n // Only required to check if the value is empty\n if (value.length == 0) {\n var fieldValue = jQuery(field).val();\n\n return parameters.indexOf(fieldValue) == -1;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n // The value is required if other field does not contain any of the specified values\n // the parameter should be formatted as data-parsley-required-unless=\"[\"#elementValueToCheck\", \"value1,value2,..\"]\"\n window.Parsley\n .addValidator('requiredUnless', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var values = utils.parseArrayStringParameter(parameters);\n\n // Get the other input's selector\n var field = values[0];\n\n // Get the values it should contain to mark this one as required\n parameters = values.slice(1);\n\n // make sure that the other element get's a change event\n utils.bindChangeToOtherElement('requiredUnless', field, fieldInstance);\n\n // Only required to check if the value is empty\n if (value.length == 0) {\n\n var fieldValue = jQuery(field).val();\n\n // It's not required if the input has one of the values\n return parameters.indexOf(fieldValue) > -1;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n // The value is required if any of the inputs are present in the dom\n // the parameter should be formatted as data-parsley-required-with=\"#elementValueToCheck,#elementValueToCheck,..\"\n window.Parsley\n .addValidator('requiredWith', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AnyPresent = false;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWith', id, fieldInstance);\n\n // If the element is in the dom and has a value\n if ($elem.length > 0 && $elem.val() != '') {\n AnyPresent = true;\n }\n });\n\n return !AnyPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n // The value is required if all other inputs are present in the dom\n // the parameter should be formatted as data-parsley-required-with-all=\"#elementValueToCheck,#elementValueToCheck,..\"\n window.Parsley\n .addValidator('requiredWithAll', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AllPresent = true;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n // If the value isn't in the dom or is empty\n if ($elem.length == 0 || $elem.val() == '') {\n AllPresent = false;\n }\n });\n\n return !AllPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n // The value is required if any of the inputs are not present in the dom\n // the parameter should be formatted as data-parsley-required-with=\"#elementValueToCheck,#elementValueToCheck,..\"\n window.Parsley\n .addValidator('requiredWithout', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AnyPresent = false;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n if ($elem.length == 0 || $elem.val() == '') {\n AnyPresent = true;\n }\n });\n\n return AnyPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n // The value is required if all other inputs are not present in the dom\n // the parameter should be formatted as data-parsley-required-with-all=\"#elementValueToCheck,#elementValueToCheck,..\"\n window.Parsley\n .addValidator('requiredWithoutAll', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AllEmpty = true;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n if ($elem.length == 1 && $elem.val() != '') {\n AllEmpty = false;\n }\n });\n\n return AllEmpty;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n var filesSizes = {\n b: 1,\n kb: 1024,\n mb: 1024 * 1024,\n gb: 1024 * 1024 * 1024,\n };\n\n // Make sure all files within the inputs are equal to or smaller than the defined size.\n window.Parsley\n .addValidator('fileSizeMax', {\n requirementType: ['integer', 'string'],\n validateString: function (value, maxSize, sizeMultiplyer, parsleyFieldInstance) {\n sizeMultiplyer = sizeMultiplyer.toLowerCase();\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the max file size\n maxSize = maxSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n console.log(maxSize);\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n console.log(files[i].size);\n if (files[i].size > maxSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) are too big.'\n }\n });\n\n\n // Make sure all files within the inputs are equal to or bigger than the defined size.\n window.Parsley\n .addValidator('fileSizeMin', {\n requirementType: ['integer', 'string'],\n validateString: function (value, minSize, sizeMultiplyer, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the min file size\n minSize = minSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (files[i].size < minSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) should are too small.'\n }\n });\n\n\n // Make sure all files within the inputs are between the defined sizes.\n window.Parsley\n .addValidator('fileSizeBetween', {\n requirementType: ['integer', 'integer', 'string'],\n validateString: function (value, minSize, maxSize, sizeMultiplyer, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the file sizes\n minSize = minSize * filesSizes[sizeMultiplyer.toLowerCase()];\n maxSize = maxSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (files[i].size <= minSize || files[i].size >= maxSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) should be between %s and %s %s.'\n }\n });\n\n\n // Make sure all files within the input are an image\n window.Parsley\n .addValidator('image', {\n validateString: function (value, param, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (!files[i].type.match('image/*')) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'This is not an image.'\n }\n });\n\n\n // Make sure all files within the input are an image\n window.Parsley\n .addValidator('fileMimetype', {\n requirementType: 'string',\n validateString: function (value, mimetypes, parsleyFieldInstance) {\n var allMimes = utils.parseArrayStringParameter(mimetypes);\n\n var files = parsleyFieldInstance.$element[0].files;\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (allMimes.indexOf(files[i].type) == -1) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'This file does not have the correct mimetype \"%s\".'\n }\n });\n\n // Make sure all images withing the input have specific dimensions\n window.Parsley\n .addValidator('dimensions', {\n requirementType: {\n '': 'boolean',\n min_width: 'number', // Specify the minimum width the image should have\n max_width: 'number', // Specify the maximum width the image should have\n min_height: 'number', // Specify the minimum height the image should have\n max_height: 'number', // Specify the maximum height the image should have\n width: 'number', // Specify the width the image should have\n height: 'number', // Specify the height the image should have\n ratio: 'string', // Specify the ratio the image should have\n },\n validateString: function (value, param, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n var options = parsleyFieldInstance.domOptions.dimensionsOptions;\n\n // If a file is present in the input\n if (files.length > 0) {\n var defer = jQuery.Deferred();\n var _URL = window.URL || window.webkitURL;\n\n var image = new Image;\n\n // Validate once t he image is loaded\n image.onload = function () {\n var width = this.width;\n var height = this.height;\n\n // Check min width, if defined\n if (typeof options.min_width != 'undefined') {\n if (width < options.min_width) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check max width, if defined\n if (typeof options.max_width != 'undefined') {\n if (width > options.max_width) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check min height, if defined\n if (typeof options.min_height != 'undefined') {\n if (height < options.min_height) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check max height, if defined\n if (typeof options.max_height != 'undefined') {\n if (height > options.max_height) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check width, if defined\n if (typeof options.width != 'undefined') {\n if (width != options.width) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check height, if defined\n if (typeof options.height != 'undefined') {\n if (height != options.height) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check ratio, if defined\n if (typeof options.ratio != 'undefined') {\n var splitRatio = options.ratio.split(':');\n if (splitRatio[0] / splitRatio[1] != width / height) {\n defer.reject(image);\n return true;\n }\n }\n\n defer.resolve(image);\n };\n\n // On error, reject the promise\n image.onerror = function () {\n console.warn('image load error');\n defer.reject();\n }\n\n image.src = _URL.createObjectURL(files[0]);\n\n return defer.promise().then(function(image){\n // Clean up\n image = null;\n\n return true;\n }, function(image){\n // Clean up\n image = null;\n\n return false;\n });\n }\n\n return true;\n }\n });\n\n /**\n * Overwrite core Parsley methods.\n *\n * @type {{_isRequired: Window.ParsleyExtend._isRequired}}\n */\n window.ParsleyExtend = {\n // Normally this was intended Internal only.\n // Field is required if have required constraint without `false` value\n _isRequired: function () {\n\n var requiredRules = [\n // This one comes out of the box with parsley\n 'required',\n\n // These ones were added with this library\n 'requiredIf', 'requiredUnless', 'requiredWith', 'requiredWithAll', 'requiredWithout', 'requiredWithoutAll'\n ];\n\n var requiredRulesFound = [];\n\n // Loop over the list to check if they're defined on the field.\n requiredRules.forEach(function (rule) {\n if ('undefined' !== typeof this.constraintsByName[rule]) {\n requiredRulesFound.push(rule);\n }\n }, this);\n\n // If there's not one required rule, return false\n if (requiredRulesFound.length == 0)\n return false;\n\n // If parsley's on required rule was found\n if (requiredRulesFound.indexOf('required') >= 0) {\n // Check if the flag is set to true\n return false !== this.constraintsByName.required.requirements;\n }\n\n return true;\n }\n };\n\n var main = utils;\n\n return main;\n\n}));\n","// Check if the value is within a comma-separated list (val1,val2,..)\nwindow.Parsley\n .addValidator('in', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n var possibles = parameter.split(',');\n\n return possibles.indexOf(value) > -1;\n },\n messages: {\n en: 'The value should be one of the following: \"%s\".'\n }\n });\n\n// Check if the value is not in a comma-separated list (val1,val2,..)\nwindow.Parsley\n .addValidator('notIn', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n var possibles = parameter.split(',');\n\n return possibles.indexOf(value) == -1;\n },\n messages: {\n en: 'The value should not be one of the following: \"%s\".'\n }\n });","import moment from 'moment';\nimport jQuery from 'jquery';\n\n// Valid date formats\nwindow.Parsley.options.dateFormats = ['DD/MM/YY', 'DD/MM/YYYY', 'MM/DD/YY', 'MM/DD/YYYY', 'YY/MM/DD', 'YYYY/MM/DD'];\n\n// Check if the value is a date\nwindow.Parsley\n .addValidator('date', {\n requirementType: 'boolean',\n validateString: function (value, state, parsleyInstance) {\n return moment(value, formatDatePhpToJs.getDateFormatsOption(parsleyInstance), true).isValid();\n },\n messages: {\n en: 'You should provide a valid date.'\n }\n });\n\n\n// Check if the value is a date in a specific format\nwindow.Parsley\n .addValidator('dateFormat', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n return moment(value, formatDatePhpToJs.convert(parameter), true).isValid();\n },\n messages: {\n en: 'The date you entered is not in the right format (%s).'\n }\n });\n\n\n// Check if the value is a date before the specified date\nwindow.Parsley\n .addValidator('before', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n\n var beforeDate = moment(parameter, dateFormats, true);\n\n // If it's not a valid date, error\n if (beforeDate === false)\n return false;\n\n return moment(value, dateFormats) < beforeDate;\n },\n messages: {\n en: 'The date you entered should be before %s.'\n }\n });\n\n// Check if the value is a date before the specified date (from another input)\nwindow.Parsley\n .addValidator('beforeInput', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var beforeInput = jQuery(parameter);\n\n // If we can't find the input, return true\n if (beforeInput.length == 0)\n return true;\n\n var beforeVal = beforeInput.val();\n\n // If the val is empty, return true\n if (beforeVal == '')\n return true;\n\n var beforeDate = moment(beforeVal, dateFormats, true);\n\n // If the before date isn't valid, error out\n if (beforeDate.isValid() === false) {\n console.warn(parameter + ' input does not contain a valid date');\n return false;\n }\n\n var thisDate = moment(value, dateFormats, true);\n\n // If the value's date isn't valid, error out\n if (thisDate.isValid() === false) {\n console.warn('the input being checked does not contain a valid date');\n return false;\n }\n\n return thisDate < beforeDate;\n },\n messages: {\n en: 'The date you entered should be before %s.'\n }\n });\n\n\n// Check if the value is a date before the specified date\nwindow.Parsley\n .addValidator('after', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var afterDate = moment(parameter, dateFormats, true);\n\n // If it's not a valid date, error\n if (afterDate === false)\n return false;\n\n return moment(value, dateFormats) > afterDate;\n },\n messages: {\n en: 'The date you entered should be after %s.'\n }\n });\n\n// Check if the value is a date before the specified date (from another input)\nwindow.Parsley\n .addValidator('afterInput', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var afterInput = jQuery(parameter);\n\n console.log(this, dateFormats);\n\n // If we can't find the input, return true\n if (afterInput.length == 0)\n return true;\n\n var afterVal = afterInput.val();\n\n // If the val is empty, return true\n if (afterVal == '')\n return true;\n\n var afterDate = moment(afterVal, dateFormats, true);\n\n // If the after date isn't valid, error out\n if (afterDate.isValid() === false) {\n console.warn(parameter + ' input does not contain a valid date');\n return false;\n }\n\n var thisDate = moment(value, dateFormats, true);\n\n // If the value's date isn't valid, error out\n if (thisDate.isValid() === false) {\n console.warn('the input being checked does not contain a valid date');\n return false;\n }\n\n return thisDate > afterDate;\n },\n messages: {\n en: 'The date you entered should be after %s.'\n }\n });\n\n// convert PHP date format to moment JS date format\nvar formatDatePhpToJs = window.formatDatePhpToJs = {\n mapChars: {\n d: 'DD',\n D: 'ddd',\n j: 'D',\n l: 'dddd',\n N: 'E',\n S: function () {\n return '[' + this.format('Do', true).replace(/\\d*/g, '') + ']';\n },\n w: 'd',\n z: function () {\n return this.format('DDD', true) - 1;\n },\n W: 'W',\n F: 'MMMM',\n m: 'MM',\n M: 'MMM',\n n: 'M',\n t: function () {\n return this.daysInMonth();\n },\n L: function () {\n return this.isLeapYear() ? 1 : 0;\n },\n o: 'GGGG',\n Y: 'YYYY',\n y: 'YY',\n a: 'a',\n A: 'A',\n B: function () {\n var thisUTC = this.clone().utc(),\n // Shamelessly stolen from http://javascript.about.com/library/blswatch.htm\n swatch = ((thisUTC.hours() + 1) % 24) + (thisUTC.minutes() / 60) + (thisUTC.seconds() / 3600);\n return Math.floor(swatch * 1000 / 24);\n },\n g: 'h',\n G: 'H',\n h: 'hh',\n H: 'HH',\n i: 'mm',\n s: 'ss',\n u: '[u]', // not sure if moment has this\n e: '[e]', // moment does not have this\n I: function () {\n return this.isDST() ? 1 : 0;\n },\n O: 'ZZ',\n P: 'Z',\n T: '[T]', // deprecated in moment\n Z: function () {\n return parseInt(this.format('ZZ', true), 10) * 36;\n },\n c: 'YYYY-MM-DD[T]HH:mm:ssZ',\n r: 'ddd, DD MMM YYYY HH:mm:ss ZZ',\n U: 'X'\n },\n formatEx: /[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g,\n convert: function (PHPDateFormat) {\n return PHPDateFormat.replace(this.formatEx, function (phpStr) {\n console.log(formatDatePhpToJs.mapChars[phpStr]);\n return typeof formatDatePhpToJs.mapChars[phpStr] === 'function' ? formatDatePhpToJs.mapChars[phpStr].call(moment()) : formatDatePhpToJs.mapChars[phpStr];\n })\n },\n getDateFormatsOption: function (parsleyInstance) {\n if (typeof parsleyInstance.options.dateFormats == 'undefined') {\n return this.getDateFormatsOption(parsleyInstance.parent);\n }\n\n return parsleyInstance.options.dateFormats;\n }\n}","import jQuery from 'jquery';\n\n/**\n * Helper functions.\n *\n * @type {{parseArrayStringParameter: larapars.parseArrayStringParameter, bindChangeToOtherElement: larapars.bindChangeToOtherElement, getDateFormatsOption: larapars.getDateFormatsOption}}\n */\nexport default {\n parseArrayStringParameter: function (parameter) {\n var m = parameter.match(/^\\s*\\[(.*)\\]\\s*$/);\n\n if (!m)\n throw 'Requirement is not an array: \"' + parameter + '\"';\n\n return m[1].replace(/\\'+/g, '').split(',');\n },\n /**\n * This is used by various validation rules that rely on another input for validation.\n *\n * This function adds a 'change' event listener which forces the original to be validated again.\n *\n * @param rule Name of the rule this change handler is for\n * @param element Which element to bind this to\n * @param fieldInstance The ParsleyFieldInstance we can call validate() on\n * @param originalNotEmpty Should the original element not be empty? (optional, default false)\n */\n bindChangeToOtherElement: function (rule, element, fieldInstance, originalNotEmpty) {\n var $elem = jQuery(element);\n var elData = $elem.data('larapars-rules');\n\n // None were added yet, initialise\n if (elData === undefined) {\n elData = [rule];\n $elem.data('larapars-rules', elData);\n }\n // Initialised, but not present\n else if (elData.indexOf(rule) == -1) {\n elData.push(rule);\n $elem.data('larapars-rules', elData);\n }\n // Already bound\n else {\n return;\n }\n\n // If not yet bound\n $elem.on('change', function () {\n if (originalNotEmpty === true && jQuery(fieldInstance.$element.get(0)).val() != '') {\n fieldInstance.validate();\n }\n else if (originalNotEmpty !== true) {\n fieldInstance.validate();\n }\n });\n }\n};","import jQuery from 'jquery';\nimport utils from '../utils.js';\n\n// Check if the value is different from the specified input's value\nwindow.Parsley\n .addValidator('different', {\n requirementType: 'string',\n validateString: function (value, parameter, fieldInstance) {\n if (jQuery(parameter).length == 0)\n return true;\n\n utils.bindChangeToOtherElement('different', parameter, fieldInstance, true);\n\n return jQuery(parameter).val() != value;\n },\n messages: {\n en: 'The value should not be the same as \"%s\".'\n }\n });\n\n// Check if the value is greater than min and smaller than max\nwindow.Parsley\n .addValidator('between', {\n requirementType: ['integer', 'integer'],\n validateNumber: function (value, min, max) {\n return value > min && value < max;\n },\n messages: {\n en: 'The value should be between \"%s\" and \"%s\".'\n }\n });\n\n// Check if the value is equal to the provided value\nwindow.Parsley\n .addValidator('sizeNumber', {\n requirementType: 'integer',\n validateNumber: function (value, parameter) {\n return value == parameter;\n },\n messages: {\n en: 'The value should be \"%s\".'\n }\n });\n\n// Check if the value's length is equal to the provided value\nwindow.Parsley\n .addValidator('sizeString', {\n requirementType: 'integer',\n validateString: function (value, parameter) {\n return value.length == parameter;\n },\n messages: {\n en: 'The value should be \"%s\" characters long.'\n }\n });\n\n\n\n// Check if each value is distinct\nwindow.Parsley\n .addValidator('distinct', {\n requirementType: 'boolean',\n validateMultiple: function (values) {\n var storedValues = [];\n var isDistinct = true;\n\n values.forEach(function (value) {\n if (storedValues.indexOf(value) > -1) {\n isDistinct = false;\n return false;\n }\n\n storedValues.push(value);\n });\n\n return isDistinct;\n },\n messages: {\n en: 'Not all values are distinct.'\n }\n });\n\n\n\n// The value should be located in one of the checkbox's checked values\nwindow.Parsley\n .addValidator('inArray', {\n requirementType: 'string',\n validateString: function (value, otherFieldName, parsleyInstance) {\n var thisElement = jQuery(parsleyInstance.$element.get(0));\n\n var values = [];\n\n // Check if we're dealing with a text field\n if (otherFieldName.substring(0, 1) == '#') {\n // Bind a change event\n utils.bindChangeToOtherElement('inArray', otherFieldName, parsleyInstance, true);\n\n // If it's a text field we're assuming that it's a list of comma separated values\n return jQuery(otherFieldName).val().split(',').indexOf(value) > -1;\n }\n\n // Bind a change handler to the checkboxes\n jQuery('input:checkbox[name=\"' + otherFieldName + '\"]').each(function () {\n utils.bindChangeToOtherElement('inArray', this, parsleyInstance, true);\n });\n\n // Get the selected values of a checkbox by it's name\n jQuery('input:checkbox[name=\"' + otherFieldName + '\"]:checked').each(function () {\n values.push(jQuery(this).val());\n });\n\n // Check if the value is in there\n return values.indexOf(value) > -1;\n },\n messages: {\n en: 'This value is incorrect.'\n }\n });","import jQuery from 'jquery';\nimport utils from '../utils.js';\n\n// The value is required only if another input's value matched one of the defined ones.\n// the parameter should be formatted as data-parsley-required-if=\"[\"#elementValueToCheck\", \"value1,value2,..\"]\"\nwindow.Parsley\n .addValidator('requiredIf', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var values = utils.parseArrayStringParameter(parameters);\n\n // Get the other input's selector\n var field = values[0];\n\n // Get the values it should contain to mark this one as required\n parameters = values.slice(1);\n\n // make sure that the other element get's a change event\n utils.bindChangeToOtherElement('requiredIf', field, fieldInstance);\n\n // Only required to check if the value is empty\n if (value.length == 0) {\n var fieldValue = jQuery(field).val();\n\n return parameters.indexOf(fieldValue) == -1;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n// The value is required if other field does not contain any of the specified values\n// the parameter should be formatted as data-parsley-required-unless=\"[\"#elementValueToCheck\", \"value1,value2,..\"]\"\nwindow.Parsley\n .addValidator('requiredUnless', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var values = utils.parseArrayStringParameter(parameters);\n\n // Get the other input's selector\n var field = values[0];\n\n // Get the values it should contain to mark this one as required\n parameters = values.slice(1);\n\n // make sure that the other element get's a change event\n utils.bindChangeToOtherElement('requiredUnless', field, fieldInstance);\n\n // Only required to check if the value is empty\n if (value.length == 0) {\n\n var fieldValue = jQuery(field).val();\n\n // It's not required if the input has one of the values\n return parameters.indexOf(fieldValue) > -1;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n// The value is required if any of the inputs are present in the dom\n// the parameter should be formatted as data-parsley-required-with=\"#elementValueToCheck,#elementValueToCheck,..\"\nwindow.Parsley\n .addValidator('requiredWith', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AnyPresent = false;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWith', id, fieldInstance);\n\n // If the element is in the dom and has a value\n if ($elem.length > 0 && $elem.val() != '') {\n AnyPresent = true;\n }\n });\n\n return !AnyPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n// The value is required if all other inputs are present in the dom\n// the parameter should be formatted as data-parsley-required-with-all=\"#elementValueToCheck,#elementValueToCheck,..\"\nwindow.Parsley\n .addValidator('requiredWithAll', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AllPresent = true;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n // If the value isn't in the dom or is empty\n if ($elem.length == 0 || $elem.val() == '') {\n AllPresent = false;\n }\n });\n\n return !AllPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n// The value is required if any of the inputs are not present in the dom\n// the parameter should be formatted as data-parsley-required-with=\"#elementValueToCheck,#elementValueToCheck,..\"\nwindow.Parsley\n .addValidator('requiredWithout', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AnyPresent = false;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n if ($elem.length == 0 || $elem.val() == '') {\n AnyPresent = true;\n }\n });\n\n return AnyPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n// The value is required if all other inputs are not present in the dom\n// the parameter should be formatted as data-parsley-required-with-all=\"#elementValueToCheck,#elementValueToCheck,..\"\nwindow.Parsley\n .addValidator('requiredWithoutAll', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AllEmpty = true;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n if ($elem.length == 1 && $elem.val() != '') {\n AllEmpty = false;\n }\n });\n\n return AllEmpty;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });","import jQuery from 'jquery';\nimport utils from '../utils.js';\n\nvar filesSizes = {\n b: 1,\n kb: 1024,\n mb: 1024 * 1024,\n gb: 1024 * 1024 * 1024,\n};\n\n// Make sure all files within the inputs are equal to or smaller than the defined size.\nwindow.Parsley\n .addValidator('fileSizeMax', {\n requirementType: ['integer', 'string'],\n validateString: function (value, maxSize, sizeMultiplyer, parsleyFieldInstance) {\n sizeMultiplyer = sizeMultiplyer.toLowerCase();\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the max file size\n maxSize = maxSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n console.log(maxSize);\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n console.log(files[i].size);\n if (files[i].size > maxSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) are too big.'\n }\n });\n\n\n// Make sure all files within the inputs are equal to or bigger than the defined size.\nwindow.Parsley\n .addValidator('fileSizeMin', {\n requirementType: ['integer', 'string'],\n validateString: function (value, minSize, sizeMultiplyer, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the min file size\n minSize = minSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (files[i].size < minSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) should are too small.'\n }\n });\n\n\n// Make sure all files within the inputs are between the defined sizes.\nwindow.Parsley\n .addValidator('fileSizeBetween', {\n requirementType: ['integer', 'integer', 'string'],\n validateString: function (value, minSize, maxSize, sizeMultiplyer, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the file sizes\n minSize = minSize * filesSizes[sizeMultiplyer.toLowerCase()];\n maxSize = maxSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (files[i].size <= minSize || files[i].size >= maxSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) should be between %s and %s %s.'\n }\n });\n\n\n// Make sure all files within the input are an image\nwindow.Parsley\n .addValidator('image', {\n validateString: function (value, param, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (!files[i].type.match('image/*')) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'This is not an image.'\n }\n });\n\n\n// Make sure all files within the input are an image\nwindow.Parsley\n .addValidator('fileMimetype', {\n requirementType: 'string',\n validateString: function (value, mimetypes, parsleyFieldInstance) {\n var allMimes = utils.parseArrayStringParameter(mimetypes);\n\n var files = parsleyFieldInstance.$element[0].files;\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (allMimes.indexOf(files[i].type) == -1) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'This file does not have the correct mimetype \"%s\".'\n }\n });\n\n// Make sure all images withing the input have specific dimensions\nwindow.Parsley\n .addValidator('dimensions', {\n requirementType: {\n '': 'boolean',\n min_width: 'number', // Specify the minimum width the image should have\n max_width: 'number', // Specify the maximum width the image should have\n min_height: 'number', // Specify the minimum height the image should have\n max_height: 'number', // Specify the maximum height the image should have\n width: 'number', // Specify the width the image should have\n height: 'number', // Specify the height the image should have\n ratio: 'string', // Specify the ratio the image should have\n },\n validateString: function (value, param, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n var options = parsleyFieldInstance.domOptions.dimensionsOptions;\n\n // If a file is present in the input\n if (files.length > 0) {\n var defer = jQuery.Deferred();\n var _URL = window.URL || window.webkitURL;\n\n var image = new Image;\n\n // Validate once t he image is loaded\n image.onload = function () {\n var width = this.width;\n var height = this.height;\n\n // Check min width, if defined\n if (typeof options.min_width != 'undefined') {\n if (width < options.min_width) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check max width, if defined\n if (typeof options.max_width != 'undefined') {\n if (width > options.max_width) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check min height, if defined\n if (typeof options.min_height != 'undefined') {\n if (height < options.min_height) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check max height, if defined\n if (typeof options.max_height != 'undefined') {\n if (height > options.max_height) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check width, if defined\n if (typeof options.width != 'undefined') {\n if (width != options.width) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check height, if defined\n if (typeof options.height != 'undefined') {\n if (height != options.height) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check ratio, if defined\n if (typeof options.ratio != 'undefined') {\n var splitRatio = options.ratio.split(':');\n if (splitRatio[0] / splitRatio[1] != width / height) {\n defer.reject(image);\n return true;\n }\n }\n\n defer.resolve(image);\n };\n\n // On error, reject the promise\n image.onerror = function () {\n console.warn('image load error');\n defer.reject();\n }\n\n image.src = _URL.createObjectURL(files[0]);\n\n return defer.promise().then(function(image){\n // Clean up\n image = null;\n\n return true;\n }, function(image){\n // Clean up\n image = null;\n\n return false;\n });\n }\n\n return true;\n }\n });","import jQuery from 'jquery';\nimport './rules/ins';\nimport './rules/dates';\nimport './rules/comparison';\nimport './rules/requireds.js';\nimport './rules/files.js';\nimport './utils.js';\n\n/**\n * Overwrite core Parsley methods.\n *\n * @type {{_isRequired: Window.ParsleyExtend._isRequired}}\n */\nwindow.ParsleyExtend = {\n // Normally this was intended Internal only.\n // Field is required if have required constraint without `false` value\n _isRequired: function () {\n\n var requiredRules = [\n // This one comes out of the box with parsley\n 'required',\n\n // These ones were added with this library\n 'requiredIf', 'requiredUnless', 'requiredWith', 'requiredWithAll', 'requiredWithout', 'requiredWithoutAll'\n ];\n\n var requiredRulesFound = [];\n\n // Loop over the list to check if they're defined on the field.\n requiredRules.forEach(function (rule) {\n if ('undefined' !== typeof this.constraintsByName[rule]) {\n requiredRulesFound.push(rule);\n }\n }, this);\n\n // If there's not one required rule, return false\n if (requiredRulesFound.length == 0)\n return false;\n\n // If parsley's on required rule was found\n if (requiredRulesFound.indexOf('required') >= 0) {\n // Check if the flag is set to true\n return false !== this.constraintsByName.required.requirements;\n }\n\n return true;\n }\n};\n\nexport default utils;"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/dist/laravel-parsley.min.js b/dist/laravel-parsley.min.js index 3554ff5..d021cb3 100644 --- a/dist/laravel-parsley.min.js +++ b/dist/laravel-parsley.min.js @@ -1,9 +1,9 @@ /*! * ParsleyJS-LaraExtras.js - * Version 0.4.0 - built Sun, Jun 19th 2016, 12:01 am + * Version 0.4.1 - built Sun, Jun 19th 2016, 12:34 am * hhttps://github.com/happyDemon/ParsleyJS-LaraExtras * Maxim Kerstens - * MIT Licensed */ -!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r(require("jquery"),require("moment")):"function"==typeof define&&define.amd?define(["jquery","moment"],r):e.laraParsley=r(e.jQuery,e.moment)}(this,function(e,r){"use strict";window.Parsley.addValidator("in",{requirementType:"string",validateString:function(e,r){var t=r.split(",");return t.indexOf(e)>-1},messages:{en:'The value should be one of the following: "%s".'}}),window.Parsley.addValidator("notIn",{requirementType:"string",validateString:function(e,r){var t=r.split(",");return-1==t.indexOf(e)},messages:{en:'The value should not be one of the following: "%s".'}}),window.Parsley.options.dateFormats=["DD/MM/YY","DD/MM/YYYY","MM/DD/YY","MM/DD/YYYY","YY/MM/DD","YYYY/MM/DD"],window.Parsley.addValidator("date",{requirementType:"boolean",validateString:function(e,n,i){return r(e,t.getDateFormatsOption(i),!0).isValid()},messages:{en:"You should provide a valid date."}}),window.Parsley.addValidator("dateFormat",{requirementType:"string",validateString:function(e,n){return r(e,t.convert(n),!0).isValid()},messages:{en:"The date you entered is not in the right format (%s)."}}),window.Parsley.addValidator("before",{requirementType:"string",validateString:function(e,n,i){var a=t.getDateFormatsOption(i),o=r(n,a,!0);return o===!1?!1:r(e,a)u},messages:{en:"The date you entered should be before %s."}}),window.Parsley.addValidator("after",{requirementType:"string",validateString:function(e,n,i){var a=t.getDateFormatsOption(i),o=r(n,a,!0);return o===!1?!1:r(e,a)>o},messages:{en:"The date you entered should be after %s."}}),window.Parsley.addValidator("afterInput",{requirementType:"string",validateString:function(n,i,a){var o=t.getDateFormatsOption(a),s=e(i);if(console.log(this,o),0==s.length)return!0;var d=s.val();if(""==d)return!0;var l=r(d,o,!0);if(l.isValid()===!1)return console.warn(i+" input does not contain a valid date"),!1;var u=r(n,o,!0);return u.isValid()===!1?(console.warn("the input being checked does not contain a valid date"),!1):u>l},messages:{en:"The date you entered should be after %s."}});var t=window.formatDatePhpToJs={mapChars:{d:"DD",D:"ddd",j:"D",l:"dddd",N:"E",S:function(){return"["+this.format("Do",!0).replace(/\d*/g,"")+"]"},w:"d",z:function(){return this.format("DDD",!0)-1},W:"W",F:"MMMM",m:"MM",M:"MMM",n:"M",t:function(){return this.daysInMonth()},L:function(){return this.isLeapYear()?1:0},o:"GGGG",Y:"YYYY",y:"YY",a:"a",A:"A",B:function(){var e=this.clone().utc(),r=(e.hours()+1)%24+e.minutes()/60+e.seconds()/3600;return Math.floor(1e3*r/24)},g:"h",G:"H",h:"hh",H:"HH",i:"mm",s:"ss",u:"[u]",e:"[e]",I:function(){return this.isDST()?1:0},O:"ZZ",P:"Z",T:"[T]",Z:function(){return 36*parseInt(this.format("ZZ",!0),10)},c:"YYYY-MM-DD[T]HH:mm:ssZ",r:"ddd, DD MMM YYYY HH:mm:ss ZZ",U:"X"},formatEx:/[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g,convert:function(e){return e.replace(this.formatEx,function(e){return console.log(t.mapChars[e]),"function"==typeof t.mapChars[e]?t.mapChars[e].call(r()):t.mapChars[e]})},getDateFormatsOption:function(e){return"undefined"==typeof e.options.dateFormats?this.getDateFormatsOption(e.parent):e.options.dateFormats}},n={parseArrayStringParameter:function(e){var r=e.match(/^\s*\[(.*)\]\s*$/);if(!r)throw'Requirement is not an array: "'+e+'"';return r[1].replace(/\'+/g,"").split(",")},bindChangeToOtherElement:function(r,t,n,i){var a=e(t),o=a.data("larapars-rules");if(void 0===o)o=[r],a.data("larapars-rules",o);else{if(-1!=o.indexOf(r))return;o.push(r),a.data("larapars-rules",o)}a.on("change",function(){i===!0&&""!=e(n.$element.get(0)).val()?n.validate():i!==!0&&n.validate()})}};window.Parsley.addValidator("different",{requirementType:"string",validateString:function(r,t,i){return 0==e(t).length?!0:(n.bindChangeToOtherElement("different",t,i,!0),e(t).val()!=r)},messages:{en:'The value should not be the same as "%s".'}}),window.Parsley.addValidator("between",{requirementType:["integer","integer"],validateNumber:function(e,r,t){return e>r&&t>e},messages:{en:'The value should be between "%s" and "%s".'}}),window.Parsley.addValidator("sizeNumber",{requirementType:"integer",validateNumber:function(e,r){return e==r},messages:{en:'The value should be "%s".'}}),window.Parsley.addValidator("sizeString",{requirementType:"integer",validateString:function(e,r){return e.length==r},messages:{en:'The value should be "%s" characters long.'}}),window.Parsley.addValidator("distinct",{requirementType:"boolean",validateMultiple:function(e){var r=[],t=!0;return e.forEach(function(e){return r.indexOf(e)>-1?(t=!1,!1):void r.push(e)}),t},messages:{en:"Not all values are distinct."}}),window.Parsley.addValidator("inArray",{requirementType:"string",validateString:function(r,t,i){var a=(e(i.$element.get(0)),[]);return"#"==t.substring(0,1)?(n.bindChangeToOtherElement("inArray",t,i,!0),e(t).val().split(",").indexOf(r)>-1):(e('input:checkbox[name="'+t+'"]').each(function(){n.bindChangeToOtherElement("inArray",this,i,!0)}),e('input:checkbox[name="'+t+'"]:checked').each(function(){a.push(e(this).val())}),a.indexOf(r)>-1)},messages:{en:"This value is incorrect."}}),window.Parsley.addValidator("requiredIf",{requirementType:"string",validateString:function(r,t,i){var a=n.parseArrayStringParameter(t),o=a[0];if(t=a.slice(1),n.bindChangeToOtherElement("requiredIf",o,i),0==r.length){var s=e(o).val();return-1==t.indexOf(s)}return!0},messages:{en:"This field is required."}}),window.Parsley.addValidator("requiredUnless",{requirementType:"string",validateString:function(r,t,i){var a=n.parseArrayStringParameter(t),o=a[0];if(t=a.slice(1),n.bindChangeToOtherElement("requiredUnless",o,i),0==r.length){var s=e(o).val();return t.indexOf(s)>-1}return!0},messages:{en:"This field is required."}}),window.Parsley.addValidator("requiredWith",{requirementType:"string",validateString:function(r,t,i){var a=n.parseArrayStringParameter(t);if(0==r.length){var o=!1;return a.forEach(function(r){var t=e(r);n.bindChangeToOtherElement("requiredWith",r,i),t.length>0&&""!=t.val()&&(o=!0)}),!o}return!0},messages:{en:"This field is required."}}),window.Parsley.addValidator("requiredWithAll",{requirementType:"string",validateString:function(r,t,i){var a=n.parseArrayStringParameter(t);if(0==r.length){var o=!0;return a.forEach(function(r){var t=e(r);n.bindChangeToOtherElement("requiredWithAll",r,i),0!=t.length&&""!=t.val()||(o=!1)}),!o}return!0},messages:{en:"This field is required."}}),window.Parsley.addValidator("requiredWithout",{requirementType:"string",validateString:function(r,t,i){var a=n.parseArrayStringParameter(t);if(0==r.length){var o=!1;return a.forEach(function(r){var t=e(r);n.bindChangeToOtherElement("requiredWithAll",r,i),0!=t.length&&""!=t.val()||(o=!0)}),o}return!0},messages:{en:"This field is required."}}),window.Parsley.addValidator("requiredWithoutAll",{requirementType:"string",validateString:function(r,t,i){var a=n.parseArrayStringParameter(t);if(0==r.length){var o=!0;return a.forEach(function(r){var t=e(r);n.bindChangeToOtherElement("requiredWithAll",r,i),1==t.length&&""!=t.val()&&(o=!1)}),o}return!0},messages:{en:"This field is required."}});var i={b:1,kb:1024,mb:1048576,gb:1073741824};window.Parsley.addValidator("fileSizeMax",{requirementType:["integer","string"],validateString:function(e,r,t,n){t=t.toLowerCase();var a=n.$element[0].files;if(r*=i[t.toLowerCase()],console.log(r),a.length>0)for(var o=0;or)return!1;return!0},messages:{en:"Your file(s) are too big."}}),window.Parsley.addValidator("fileSizeMin",{requirementType:["integer","string"],validateString:function(e,r,t,n){var a=n.$element[0].files;if(r*=i[t.toLowerCase()],a.length>0)for(var o=0;o0)for(var s=0;s=t)return!1;return!0},messages:{en:"Your file(s) should be between %s and %s %s."}}),window.Parsley.addValidator("image",{validateString:function(e,r,t){var n=t.$element[0].files;if(n.length>0)for(var i=0;i0)for(var o=0;o0){var o=e.Deferred(),s=new FileReader;return s.onload=function(){var e=new Image;e.onload=function(){var e=this.width,r=this.height;if("undefined"!=typeof n.min_width&&(console.log(e,n.min_width),en.max_width)return void o.reject();if("undefined"!=typeof n.min_height&&rn.max_height)return void o.reject();if("undefined"!=typeof n.width&&e!=n.width)return void o.reject();if("undefined"!=typeof n.height&&r!=n.height)return void o.reject();if("undefined"!=typeof n.ratio){var t=n.ratio.split(":");if(t[0]/t[1]!=e/r)return void o.reject()}o.resolve()},e.onerror=function(){console.log("image error"),o.reject()},console.log(s.result),e.src=s.result},s.onerror=function(){console.log("file error"),o.reject()},console.log(a[0]),s.readAsDataURL(a[0]),o.promise()}return!0}}),window.ParsleyExtend={_isRequired:function(){var e=["required","requiredIf","requiredUnless","requiredWith","requiredWithAll","requiredWithout","requiredWithoutAll"],r=[];return e.forEach(function(e){"undefined"!=typeof this.constraintsByName[e]&&r.push(e)},this),0==r.length?!1:r.indexOf("required")>=0?!1!==this.constraintsByName.required.requirements:!0}};var a=n;return a}); +!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r(require("jquery"),require("moment")):"function"==typeof define&&define.amd?define(["jquery","moment"],r):e.laraParsley=r(e.jQuery,e.moment)}(this,function(e,r){"use strict";window.Parsley.addValidator("in",{requirementType:"string",validateString:function(e,r){var t=r.split(",");return t.indexOf(e)>-1},messages:{en:'The value should be one of the following: "%s".'}}),window.Parsley.addValidator("notIn",{requirementType:"string",validateString:function(e,r){var t=r.split(",");return-1==t.indexOf(e)},messages:{en:'The value should not be one of the following: "%s".'}}),window.Parsley.options.dateFormats=["DD/MM/YY","DD/MM/YYYY","MM/DD/YY","MM/DD/YYYY","YY/MM/DD","YYYY/MM/DD"],window.Parsley.addValidator("date",{requirementType:"boolean",validateString:function(e,n,i){return r(e,t.getDateFormatsOption(i),!0).isValid()},messages:{en:"You should provide a valid date."}}),window.Parsley.addValidator("dateFormat",{requirementType:"string",validateString:function(e,n){return r(e,t.convert(n),!0).isValid()},messages:{en:"The date you entered is not in the right format (%s)."}}),window.Parsley.addValidator("before",{requirementType:"string",validateString:function(e,n,i){var a=t.getDateFormatsOption(i),s=r(n,a,!0);return s===!1?!1:r(e,a)u},messages:{en:"The date you entered should be before %s."}}),window.Parsley.addValidator("after",{requirementType:"string",validateString:function(e,n,i){var a=t.getDateFormatsOption(i),s=r(n,a,!0);return s===!1?!1:r(e,a)>s},messages:{en:"The date you entered should be after %s."}}),window.Parsley.addValidator("afterInput",{requirementType:"string",validateString:function(n,i,a){var s=t.getDateFormatsOption(a),o=e(i);if(console.log(this,s),0==o.length)return!0;var d=o.val();if(""==d)return!0;var l=r(d,s,!0);if(l.isValid()===!1)return console.warn(i+" input does not contain a valid date"),!1;var u=r(n,s,!0);return u.isValid()===!1?(console.warn("the input being checked does not contain a valid date"),!1):u>l},messages:{en:"The date you entered should be after %s."}});var t=window.formatDatePhpToJs={mapChars:{d:"DD",D:"ddd",j:"D",l:"dddd",N:"E",S:function(){return"["+this.format("Do",!0).replace(/\d*/g,"")+"]"},w:"d",z:function(){return this.format("DDD",!0)-1},W:"W",F:"MMMM",m:"MM",M:"MMM",n:"M",t:function(){return this.daysInMonth()},L:function(){return this.isLeapYear()?1:0},o:"GGGG",Y:"YYYY",y:"YY",a:"a",A:"A",B:function(){var e=this.clone().utc(),r=(e.hours()+1)%24+e.minutes()/60+e.seconds()/3600;return Math.floor(1e3*r/24)},g:"h",G:"H",h:"hh",H:"HH",i:"mm",s:"ss",u:"[u]",e:"[e]",I:function(){return this.isDST()?1:0},O:"ZZ",P:"Z",T:"[T]",Z:function(){return 36*parseInt(this.format("ZZ",!0),10)},c:"YYYY-MM-DD[T]HH:mm:ssZ",r:"ddd, DD MMM YYYY HH:mm:ss ZZ",U:"X"},formatEx:/[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g,convert:function(e){return e.replace(this.formatEx,function(e){return console.log(t.mapChars[e]),"function"==typeof t.mapChars[e]?t.mapChars[e].call(r()):t.mapChars[e]})},getDateFormatsOption:function(e){return"undefined"==typeof e.options.dateFormats?this.getDateFormatsOption(e.parent):e.options.dateFormats}},n={parseArrayStringParameter:function(e){var r=e.match(/^\s*\[(.*)\]\s*$/);if(!r)throw'Requirement is not an array: "'+e+'"';return r[1].replace(/\'+/g,"").split(",")},bindChangeToOtherElement:function(r,t,n,i){var a=e(t),s=a.data("larapars-rules");if(void 0===s)s=[r],a.data("larapars-rules",s);else{if(-1!=s.indexOf(r))return;s.push(r),a.data("larapars-rules",s)}a.on("change",function(){i===!0&&""!=e(n.$element.get(0)).val()?n.validate():i!==!0&&n.validate()})}};window.Parsley.addValidator("different",{requirementType:"string",validateString:function(r,t,i){return 0==e(t).length?!0:(n.bindChangeToOtherElement("different",t,i,!0),e(t).val()!=r)},messages:{en:'The value should not be the same as "%s".'}}),window.Parsley.addValidator("between",{requirementType:["integer","integer"],validateNumber:function(e,r,t){return e>r&&t>e},messages:{en:'The value should be between "%s" and "%s".'}}),window.Parsley.addValidator("sizeNumber",{requirementType:"integer",validateNumber:function(e,r){return e==r},messages:{en:'The value should be "%s".'}}),window.Parsley.addValidator("sizeString",{requirementType:"integer",validateString:function(e,r){return e.length==r},messages:{en:'The value should be "%s" characters long.'}}),window.Parsley.addValidator("distinct",{requirementType:"boolean",validateMultiple:function(e){var r=[],t=!0;return e.forEach(function(e){return r.indexOf(e)>-1?(t=!1,!1):void r.push(e)}),t},messages:{en:"Not all values are distinct."}}),window.Parsley.addValidator("inArray",{requirementType:"string",validateString:function(r,t,i){var a=(e(i.$element.get(0)),[]);return"#"==t.substring(0,1)?(n.bindChangeToOtherElement("inArray",t,i,!0),e(t).val().split(",").indexOf(r)>-1):(e('input:checkbox[name="'+t+'"]').each(function(){n.bindChangeToOtherElement("inArray",this,i,!0)}),e('input:checkbox[name="'+t+'"]:checked').each(function(){a.push(e(this).val())}),a.indexOf(r)>-1)},messages:{en:"This value is incorrect."}}),window.Parsley.addValidator("requiredIf",{requirementType:"string",validateString:function(r,t,i){var a=n.parseArrayStringParameter(t),s=a[0];if(t=a.slice(1),n.bindChangeToOtherElement("requiredIf",s,i),0==r.length){var o=e(s).val();return-1==t.indexOf(o)}return!0},messages:{en:"This field is required."}}),window.Parsley.addValidator("requiredUnless",{requirementType:"string",validateString:function(r,t,i){var a=n.parseArrayStringParameter(t),s=a[0];if(t=a.slice(1),n.bindChangeToOtherElement("requiredUnless",s,i),0==r.length){var o=e(s).val();return t.indexOf(o)>-1}return!0},messages:{en:"This field is required."}}),window.Parsley.addValidator("requiredWith",{requirementType:"string",validateString:function(r,t,i){var a=n.parseArrayStringParameter(t);if(0==r.length){var s=!1;return a.forEach(function(r){var t=e(r);n.bindChangeToOtherElement("requiredWith",r,i),t.length>0&&""!=t.val()&&(s=!0)}),!s}return!0},messages:{en:"This field is required."}}),window.Parsley.addValidator("requiredWithAll",{requirementType:"string",validateString:function(r,t,i){var a=n.parseArrayStringParameter(t);if(0==r.length){var s=!0;return a.forEach(function(r){var t=e(r);n.bindChangeToOtherElement("requiredWithAll",r,i),0!=t.length&&""!=t.val()||(s=!1)}),!s}return!0},messages:{en:"This field is required."}}),window.Parsley.addValidator("requiredWithout",{requirementType:"string",validateString:function(r,t,i){var a=n.parseArrayStringParameter(t);if(0==r.length){var s=!1;return a.forEach(function(r){var t=e(r);n.bindChangeToOtherElement("requiredWithAll",r,i),0!=t.length&&""!=t.val()||(s=!0)}),s}return!0},messages:{en:"This field is required."}}),window.Parsley.addValidator("requiredWithoutAll",{requirementType:"string",validateString:function(r,t,i){var a=n.parseArrayStringParameter(t);if(0==r.length){var s=!0;return a.forEach(function(r){var t=e(r);n.bindChangeToOtherElement("requiredWithAll",r,i),1==t.length&&""!=t.val()&&(s=!1)}),s}return!0},messages:{en:"This field is required."}});var i={b:1,kb:1024,mb:1048576,gb:1073741824};window.Parsley.addValidator("fileSizeMax",{requirementType:["integer","string"],validateString:function(e,r,t,n){t=t.toLowerCase();var a=n.$element[0].files;if(r*=i[t.toLowerCase()],console.log(r),a.length>0)for(var s=0;sr)return!1;return!0},messages:{en:"Your file(s) are too big."}}),window.Parsley.addValidator("fileSizeMin",{requirementType:["integer","string"],validateString:function(e,r,t,n){var a=n.$element[0].files;if(r*=i[t.toLowerCase()],a.length>0)for(var s=0;s0)for(var o=0;o=t)return!1;return!0},messages:{en:"Your file(s) should be between %s and %s %s."}}),window.Parsley.addValidator("image",{validateString:function(e,r,t){var n=t.$element[0].files;if(n.length>0)for(var i=0;i0)for(var s=0;s0){var s=e.Deferred(),o=window.URL||window.webkitURL,d=new Image;return d.onload=function(){var e=this.width,r=this.height;if("undefined"!=typeof a.min_width&&ea.max_width)return s.reject(d),!0;if("undefined"!=typeof a.min_height&&ra.max_height)return s.reject(d),!0;if("undefined"!=typeof a.width&&e!=a.width)return s.reject(d),!0;if("undefined"!=typeof a.height&&r!=a.height)return s.reject(d),!0;if("undefined"!=typeof a.ratio){var t=a.ratio.split(":");if(t[0]/t[1]!=e/r)return s.reject(d),!0}s.resolve(d)},d.onerror=function(){console.warn("image load error"),s.reject()},d.src=o.createObjectURL(i[0]),s.promise().then(function(e){return e=null,!0},function(e){return e=null,!1})}return!0}}),window.ParsleyExtend={_isRequired:function(){var e=["required","requiredIf","requiredUnless","requiredWith","requiredWithAll","requiredWithout","requiredWithoutAll"],r=[];return e.forEach(function(e){"undefined"!=typeof this.constraintsByName[e]&&r.push(e)},this),0==r.length?!1:r.indexOf("required")>=0?!1!==this.constraintsByName.required.requirements:!0}};var a=n;return a}); //# sourceMappingURL=laravel-parsley.min.js.map diff --git a/dist/laravel-parsley.min.js.map b/dist/laravel-parsley.min.js.map index fd74640..cb9355e 100644 --- a/dist/laravel-parsley.min.js.map +++ b/dist/laravel-parsley.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["/source/laravel-parsley.js","/source/src/rules/ins.js","/source/src/rules/dates.js","/source/src/utils.js","/source/src/rules/comparison.js","/source/src/rules/requireds.js","/source/src/rules/files.js","/source/src/main.js"],"names":["global","factory","exports","module","require","define","amd","laraParsley","jQuery","moment","this","window","Parsley","addValidator","requirementType","validateString","value","parameter","possibles","split","indexOf","messages","en","options","dateFormats","state","parsleyInstance","formatDatePhpToJs","getDateFormatsOption","isValid","convert","beforeDate","beforeInput","length","beforeVal","val","console","warn","thisDate","afterDate","afterInput","log","afterVal","mapChars","d","D","j","l","N","S","format","replace","w","z","W","F","m","M","n","t","daysInMonth","L","isLeapYear","o","Y","y","a","A","B","thisUTC","clone","utc","swatch","hours","minutes","seconds","Math","floor","g","G","h","H","i","s","u","e","I","isDST","O","P","T","Z","parseInt","c","r","U","formatEx","PHPDateFormat","phpStr","call","parent","utils","parseArrayStringParameter","match","bindChangeToOtherElement","rule","element","fieldInstance","originalNotEmpty","$elem","elData","data","undefined","push","on","$element","get","validate","validateNumber","min","max","validateMultiple","values","storedValues","isDistinct","forEach","otherFieldName","substring","each","parameters","field","slice","fieldValue","allElements","AnyPresent","id","AllPresent","AllEmpty","filesSizes","b","kb","mb","gb","maxSize","sizeMultiplyer","parsleyFieldInstance","toLowerCase","files","size","minSize","param","type","mimetypes","allMimes","","min_width","max_width","min_height","max_height","width","height","ratio","defer","Deferred","file","FileReader","onload","image","Image","reject","splitRatio","resolve","onerror","result","src","readAsDataURL","promise","ParsleyExtend","_isRequired","requiredRules","requiredRulesFound","constraintsByName","required","requirements","main"],"mappings":";;;;;;;CAAA,SAAWA,EAAQC,GACI,gBAAZC,UAA0C,mBAAXC,QAAyBA,OAAOD,QAAUD,EAAQG,QAAQ,UAAWA,QAAQ,WACjG,kBAAXC,SAAyBA,OAAOC,IAAMD,QAAQ,SAAU,UAAWJ,GAC1ED,EAAOO,YAAcN,EAAQD,EAAOQ,OAAQR,EAAOS,SACrDC,KAAM,SAAUF,EAAQC,GAAU,YCHpCE,QAAOC,QACFC,aAAa,MACVC,gBAAiB,SACjBC,eAAgB,SAAUC,EAAOC,GAC7B,GAAIC,GAAYD,EAAUE,MAAM,IAEhC,OAAOD,GAAUE,QAAQJ,GAAS,IAEtCK,UACIC,GAAI,qDAKhBX,OAAOC,QACFC,aAAa,SACVC,gBAAiB,SACjBC,eAAgB,SAAUC,EAAOC,GAC7B,GAAIC,GAAYD,EAAUE,MAAM,IAEhC,OAAmC,IAA5BD,EAAUE,QAAQJ,IAE7BK,UACIC,GAAI,yDCpBhBX,OAAOC,QAAQW,QAAQC,aAAe,WAAY,aAAc,WAAY,aAAc,WAAY,cAGtGb,OAAOC,QACFC,aAAa,QACVC,gBAAiB,UACjBC,eAAgB,SAAUC,EAAOS,EAAOC,GACpC,MAAOjB,GAAOO,EAAOW,EAAkBC,qBAAqBF,IAAkB,GAAMG,WAExFR,UACIC,GAAI,sCA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,mBAAjBlJ,GAAQwI,OACXA,GAASxI,EAAQwI,MAEjB,WADAG,GAAMO,QAMd,IAA6B,mBAAlBlJ,GAAQyI,QACXA,GAAUzI,EAAQyI,OAElB,WADAE,GAAMO,QAMd,IAA4B,mBAAjBlJ,GAAQ0I,MAAsB,CACrC,GAAIS,GAAanJ,EAAQ0I,MAAM9I,MAAM,IAErC,IAAIuJ,EAAW,GAAKA,EAAW,IAAMX,EAAQC,EAEzC,WADAE,GAAMO,SAKdP,EAAMS,WAIVJ,EAAMK,QAAU,WACZxI,QAAQK,IAAI,eACZyH,EAAMO,UAIVrI,QAAQK,IAAI2H,EAAKS,QACjBN,EAAMO,IAAMV,EAAKS,QAIrBT,EAAKQ,QAAU,WACXxI,QAAQK,IAAI,cACZyH,EAAMO,UAIVrI,QAAQK,IAAI0G,EAAM,IAClBiB,EAAKW,cAAc5B,EAAM,IAElBe,EAAMc,UAGjB,OAAO,KClQnBrK,OAAOsK,eAGHC,YAAa,WAET,GAAIC,IAEA,WAGA,aAAc,iBAAkB,eAAgB,kBAAmB,kBAAmB,sBAGtFC,IAUJ,OAPAD,GAActD,QAAQ,SAAUpB,GACxB,mBAAuB/F,MAAK2K,kBAAkB5E,IAC9C2E,EAAmBnE,KAAKR,IAE7B/F,MAG8B,GAA7B0K,EAAmBnJ,QACZ,EAGPmJ,EAAmBhK,QAAQ,aAAe,GAEnC,IAAUV,KAAK2K,kBAAkBC,SAASC,cAG9C,GA7Cf,IAAAC,GAAAnF,CP67BI,OAAOmF","file":"laravel-parsley.min.js","sourcesContent":["(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('moment')) :\n typeof define === 'function' && define.amd ? define(['jquery', 'moment'], factory) :\n global.laraParsley = factory(global.jQuery, global.moment)\n}(this, function (jQuery, moment) { 'use strict';\n\n // Check if the value is within a comma-separated list (val1,val2,..)\n window.Parsley\n .addValidator('in', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n var possibles = parameter.split(',');\n\n return possibles.indexOf(value) > -1;\n },\n messages: {\n en: 'The value should be one of the following: \"%s\".'\n }\n });\n\n // Check if the value is not in a comma-separated list (val1,val2,..)\n window.Parsley\n .addValidator('notIn', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n var possibles = parameter.split(',');\n\n return possibles.indexOf(value) == -1;\n },\n messages: {\n en: 'The value should not be one of the following: \"%s\".'\n }\n });\n\n // Valid date formats\n window.Parsley.options.dateFormats = ['DD/MM/YY', 'DD/MM/YYYY', 'MM/DD/YY', 'MM/DD/YYYY', 'YY/MM/DD', 'YYYY/MM/DD'];\n\n // Check if the value is a date\n window.Parsley\n .addValidator('date', {\n requirementType: 'boolean',\n validateString: function (value, state, parsleyInstance) {\n return moment(value, formatDatePhpToJs.getDateFormatsOption(parsleyInstance), true).isValid();\n },\n messages: {\n en: 'You should provide a valid date.'\n }\n });\n\n\n // Check if the value is a date in a specific format\n window.Parsley\n .addValidator('dateFormat', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n return moment(value, formatDatePhpToJs.convert(parameter), true).isValid();\n },\n messages: {\n en: 'The date you entered is not in the right format (%s).'\n }\n });\n\n\n // Check if the value is a date before the specified date\n window.Parsley\n .addValidator('before', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n\n var beforeDate = moment(parameter, dateFormats, true);\n\n // If it's not a valid date, error\n if (beforeDate === false)\n return false;\n\n return moment(value, dateFormats) < beforeDate;\n },\n messages: {\n en: 'The date you entered should be before %s.'\n }\n });\n\n // Check if the value is a date before the specified date (from another input)\n window.Parsley\n .addValidator('beforeInput', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var beforeInput = jQuery(parameter);\n\n // If we can't find the input, return true\n if (beforeInput.length == 0)\n return true;\n\n var beforeVal = beforeInput.val();\n\n // If the val is empty, return true\n if (beforeVal == '')\n return true;\n\n var beforeDate = moment(beforeVal, dateFormats, true);\n\n // If the before date isn't valid, error out\n if (beforeDate.isValid() === false) {\n console.warn(parameter + ' input does not contain a valid date');\n return false;\n }\n\n var thisDate = moment(value, dateFormats, true);\n\n // If the value's date isn't valid, error out\n if (thisDate.isValid() === false) {\n console.warn('the input being checked does not contain a valid date');\n return false;\n }\n\n return thisDate < beforeDate;\n },\n messages: {\n en: 'The date you entered should be before %s.'\n }\n });\n\n\n // Check if the value is a date before the specified date\n window.Parsley\n .addValidator('after', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var afterDate = moment(parameter, dateFormats, true);\n\n // If it's not a valid date, error\n if (afterDate === false)\n return false;\n\n return moment(value, dateFormats) > afterDate;\n },\n messages: {\n en: 'The date you entered should be after %s.'\n }\n });\n\n // Check if the value is a date before the specified date (from another input)\n window.Parsley\n .addValidator('afterInput', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var afterInput = jQuery(parameter);\n\n console.log(this, dateFormats);\n\n // If we can't find the input, return true\n if (afterInput.length == 0)\n return true;\n\n var afterVal = afterInput.val();\n\n // If the val is empty, return true\n if (afterVal == '')\n return true;\n\n var afterDate = moment(afterVal, dateFormats, true);\n\n // If the after date isn't valid, error out\n if (afterDate.isValid() === false) {\n console.warn(parameter + ' input does not contain a valid date');\n return false;\n }\n\n var thisDate = moment(value, dateFormats, true);\n\n // If the value's date isn't valid, error out\n if (thisDate.isValid() === false) {\n console.warn('the input being checked does not contain a valid date');\n return false;\n }\n\n return thisDate > afterDate;\n },\n messages: {\n en: 'The date you entered should be after %s.'\n }\n });\n\n // convert PHP date format to moment JS date format\n var formatDatePhpToJs = window.formatDatePhpToJs = {\n mapChars: {\n d: 'DD',\n D: 'ddd',\n j: 'D',\n l: 'dddd',\n N: 'E',\n S: function () {\n return '[' + this.format('Do', true).replace(/\\d*/g, '') + ']';\n },\n w: 'd',\n z: function () {\n return this.format('DDD', true) - 1;\n },\n W: 'W',\n F: 'MMMM',\n m: 'MM',\n M: 'MMM',\n n: 'M',\n t: function () {\n return this.daysInMonth();\n },\n L: function () {\n return this.isLeapYear() ? 1 : 0;\n },\n o: 'GGGG',\n Y: 'YYYY',\n y: 'YY',\n a: 'a',\n A: 'A',\n B: function () {\n var thisUTC = this.clone().utc(),\n // Shamelessly stolen from http://javascript.about.com/library/blswatch.htm\n swatch = ((thisUTC.hours() + 1) % 24) + (thisUTC.minutes() / 60) + (thisUTC.seconds() / 3600);\n return Math.floor(swatch * 1000 / 24);\n },\n g: 'h',\n G: 'H',\n h: 'hh',\n H: 'HH',\n i: 'mm',\n s: 'ss',\n u: '[u]', // not sure if moment has this\n e: '[e]', // moment does not have this\n I: function () {\n return this.isDST() ? 1 : 0;\n },\n O: 'ZZ',\n P: 'Z',\n T: '[T]', // deprecated in moment\n Z: function () {\n return parseInt(this.format('ZZ', true), 10) * 36;\n },\n c: 'YYYY-MM-DD[T]HH:mm:ssZ',\n r: 'ddd, DD MMM YYYY HH:mm:ss ZZ',\n U: 'X'\n },\n formatEx: /[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g,\n convert: function (PHPDateFormat) {\n return PHPDateFormat.replace(this.formatEx, function (phpStr) {\n console.log(formatDatePhpToJs.mapChars[phpStr]);\n return typeof formatDatePhpToJs.mapChars[phpStr] === 'function' ? formatDatePhpToJs.mapChars[phpStr].call(moment()) : formatDatePhpToJs.mapChars[phpStr];\n })\n },\n getDateFormatsOption: function (parsleyInstance) {\n if (typeof parsleyInstance.options.dateFormats == 'undefined') {\n return this.getDateFormatsOption(parsleyInstance.parent);\n }\n\n return parsleyInstance.options.dateFormats;\n }\n }\n\n /**\n * Helper functions.\n *\n * @type {{parseArrayStringParameter: larapars.parseArrayStringParameter, bindChangeToOtherElement: larapars.bindChangeToOtherElement, getDateFormatsOption: larapars.getDateFormatsOption}}\n */\n var utils = {\n parseArrayStringParameter: function (parameter) {\n var m = parameter.match(/^\\s*\\[(.*)\\]\\s*$/);\n\n if (!m)\n throw 'Requirement is not an array: \"' + parameter + '\"';\n\n return m[1].replace(/\\'+/g, '').split(',');\n },\n /**\n * This is used by various validation rules that rely on another input for validation.\n *\n * This function adds a 'change' event listener which forces the original to be validated again.\n *\n * @param rule Name of the rule this change handler is for\n * @param element Which element to bind this to\n * @param fieldInstance The ParsleyFieldInstance we can call validate() on\n * @param originalNotEmpty Should the original element not be empty? (optional, default false)\n */\n bindChangeToOtherElement: function (rule, element, fieldInstance, originalNotEmpty) {\n var $elem = jQuery(element);\n var elData = $elem.data('larapars-rules');\n\n // None were added yet, initialise\n if (elData === undefined) {\n elData = [rule];\n $elem.data('larapars-rules', elData);\n }\n // Initialised, but not present\n else if (elData.indexOf(rule) == -1) {\n elData.push(rule);\n $elem.data('larapars-rules', elData);\n }\n // Already bound\n else {\n return;\n }\n\n // If not yet bound\n $elem.on('change', function () {\n if (originalNotEmpty === true && jQuery(fieldInstance.$element.get(0)).val() != '') {\n fieldInstance.validate();\n }\n else if (originalNotEmpty !== true) {\n fieldInstance.validate();\n }\n });\n }\n };\n\n // Check if the value is different from the specified input's value\n window.Parsley\n .addValidator('different', {\n requirementType: 'string',\n validateString: function (value, parameter, fieldInstance) {\n if (jQuery(parameter).length == 0)\n return true;\n\n utils.bindChangeToOtherElement('different', parameter, fieldInstance, true);\n\n return jQuery(parameter).val() != value;\n },\n messages: {\n en: 'The value should not be the same as \"%s\".'\n }\n });\n\n // Check if the value is greater than min and smaller than max\n window.Parsley\n .addValidator('between', {\n requirementType: ['integer', 'integer'],\n validateNumber: function (value, min, max) {\n return value > min && value < max;\n },\n messages: {\n en: 'The value should be between \"%s\" and \"%s\".'\n }\n });\n\n // Check if the value is equal to the provided value\n window.Parsley\n .addValidator('sizeNumber', {\n requirementType: 'integer',\n validateNumber: function (value, parameter) {\n return value == parameter;\n },\n messages: {\n en: 'The value should be \"%s\".'\n }\n });\n\n // Check if the value's length is equal to the provided value\n window.Parsley\n .addValidator('sizeString', {\n requirementType: 'integer',\n validateString: function (value, parameter) {\n return value.length == parameter;\n },\n messages: {\n en: 'The value should be \"%s\" characters long.'\n }\n });\n\n\n\n // Check if each value is distinct\n window.Parsley\n .addValidator('distinct', {\n requirementType: 'boolean',\n validateMultiple: function (values) {\n var storedValues = [];\n var isDistinct = true;\n\n values.forEach(function (value) {\n if (storedValues.indexOf(value) > -1) {\n isDistinct = false;\n return false;\n }\n\n storedValues.push(value);\n });\n\n return isDistinct;\n },\n messages: {\n en: 'Not all values are distinct.'\n }\n });\n\n\n\n // The value should be located in one of the checkbox's checked values\n window.Parsley\n .addValidator('inArray', {\n requirementType: 'string',\n validateString: function (value, otherFieldName, parsleyInstance) {\n var thisElement = jQuery(parsleyInstance.$element.get(0));\n\n var values = [];\n\n // Check if we're dealing with a text field\n if (otherFieldName.substring(0, 1) == '#') {\n // Bind a change event\n utils.bindChangeToOtherElement('inArray', otherFieldName, parsleyInstance, true);\n\n // If it's a text field we're assuming that it's a list of comma separated values\n return jQuery(otherFieldName).val().split(',').indexOf(value) > -1;\n }\n\n // Bind a change handler to the checkboxes\n jQuery('input:checkbox[name=\"' + otherFieldName + '\"]').each(function () {\n utils.bindChangeToOtherElement('inArray', this, parsleyInstance, true);\n });\n\n // Get the selected values of a checkbox by it's name\n jQuery('input:checkbox[name=\"' + otherFieldName + '\"]:checked').each(function () {\n values.push(jQuery(this).val());\n });\n\n // Check if the value is in there\n return values.indexOf(value) > -1;\n },\n messages: {\n en: 'This value is incorrect.'\n }\n });\n\n // The value is required only if another input's value matched one of the defined ones.\n // the parameter should be formatted as data-parsley-required-if=\"[\"#elementValueToCheck\", \"value1,value2,..\"]\"\n window.Parsley\n .addValidator('requiredIf', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var values = utils.parseArrayStringParameter(parameters);\n\n // Get the other input's selector\n var field = values[0];\n\n // Get the values it should contain to mark this one as required\n parameters = values.slice(1);\n\n // make sure that the other element get's a change event\n utils.bindChangeToOtherElement('requiredIf', field, fieldInstance);\n\n // Only required to check if the value is empty\n if (value.length == 0) {\n var fieldValue = jQuery(field).val();\n\n return parameters.indexOf(fieldValue) == -1;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n // The value is required if other field does not contain any of the specified values\n // the parameter should be formatted as data-parsley-required-unless=\"[\"#elementValueToCheck\", \"value1,value2,..\"]\"\n window.Parsley\n .addValidator('requiredUnless', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var values = utils.parseArrayStringParameter(parameters);\n\n // Get the other input's selector\n var field = values[0];\n\n // Get the values it should contain to mark this one as required\n parameters = values.slice(1);\n\n // make sure that the other element get's a change event\n utils.bindChangeToOtherElement('requiredUnless', field, fieldInstance);\n\n // Only required to check if the value is empty\n if (value.length == 0) {\n\n var fieldValue = jQuery(field).val();\n\n // It's not required if the input has one of the values\n return parameters.indexOf(fieldValue) > -1;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n // The value is required if any of the inputs are present in the dom\n // the parameter should be formatted as data-parsley-required-with=\"#elementValueToCheck,#elementValueToCheck,..\"\n window.Parsley\n .addValidator('requiredWith', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AnyPresent = false;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWith', id, fieldInstance);\n\n // If the element is in the dom and has a value\n if ($elem.length > 0 && $elem.val() != '') {\n AnyPresent = true;\n }\n });\n\n return !AnyPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n // The value is required if all other inputs are present in the dom\n // the parameter should be formatted as data-parsley-required-with-all=\"#elementValueToCheck,#elementValueToCheck,..\"\n window.Parsley\n .addValidator('requiredWithAll', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AllPresent = true;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n // If the value isn't in the dom or is empty\n if ($elem.length == 0 || $elem.val() == '') {\n AllPresent = false;\n }\n });\n\n return !AllPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n // The value is required if any of the inputs are not present in the dom\n // the parameter should be formatted as data-parsley-required-with=\"#elementValueToCheck,#elementValueToCheck,..\"\n window.Parsley\n .addValidator('requiredWithout', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AnyPresent = false;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n if ($elem.length == 0 || $elem.val() == '') {\n AnyPresent = true;\n }\n });\n\n return AnyPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n // The value is required if all other inputs are not present in the dom\n // the parameter should be formatted as data-parsley-required-with-all=\"#elementValueToCheck,#elementValueToCheck,..\"\n window.Parsley\n .addValidator('requiredWithoutAll', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AllEmpty = true;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n if ($elem.length == 1 && $elem.val() != '') {\n AllEmpty = false;\n }\n });\n\n return AllEmpty;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n var filesSizes = {\n b: 1,\n kb: 1024,\n mb: 1024 * 1024,\n gb: 1024 * 1024 * 1024,\n };\n\n // Make sure all files within the inputs are equal to or smaller than the defined size.\n window.Parsley\n .addValidator('fileSizeMax', {\n requirementType: ['integer', 'string'],\n validateString: function (value, maxSize, sizeMultiplyer, parsleyFieldInstance) {\n sizeMultiplyer = sizeMultiplyer.toLowerCase();\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the max file size\n maxSize = maxSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n console.log(maxSize);\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n console.log(files[i].size);\n if (files[i].size > maxSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) are too big.'\n }\n });\n\n\n // Make sure all files within the inputs are equal to or bigger than the defined size.\n window.Parsley\n .addValidator('fileSizeMin', {\n requirementType: ['integer', 'string'],\n validateString: function (value, minSize, sizeMultiplyer, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the min file size\n minSize = minSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (files[i].size < minSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) should are too small.'\n }\n });\n\n\n // Make sure all files within the inputs are between the defined sizes.\n window.Parsley\n .addValidator('fileSizeBetween', {\n requirementType: ['integer', 'integer', 'string'],\n validateString: function (value, minSize, maxSize, sizeMultiplyer, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the file sizes\n minSize = minSize * filesSizes[sizeMultiplyer.toLowerCase()];\n maxSize = maxSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (files[i].size <= minSize || files[i].size >= maxSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) should be between %s and %s %s.'\n }\n });\n\n\n // Make sure all files within the input are an image\n window.Parsley\n .addValidator('image', {\n validateString: function (value, param, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (!files[i].type.match('image/*')) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'This is not an image.'\n }\n });\n\n\n // Make sure all files within the input are an image\n window.Parsley\n .addValidator('fileMimetype', {\n requirementType: 'string',\n validateString: function (value, mimetypes, parsleyFieldInstance) {\n var allMimes = utils.parseArrayStringParameter(mimetypes);\n\n var files = parsleyFieldInstance.$element[0].files;\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (allMimes.indexOf(files[i].type) == -1) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'This file does not have the correct mimetype \"%s\".'\n }\n });\n\n // Make sure all images withing the input have specific dimensions\n\n //Parsley.addAsyncValidator();\n\n\n window.Parsley\n .addValidator('dimensions', {\n requirementType: {\n '': 'boolean',\n min_width: 'number', // Specify the minimum width the image should have\n max_width: 'number', // Specify the maximum width the image should have\n min_height: 'number', // Specify the minimum height the image should have\n max_height: 'number', // Specify the maximum height the image should have\n width: 'number', // Specify the width the image should have\n height: 'number', // Specify the height the image should have\n ratio: 'string', // Specify the ratio the image should have\n },\n validateString: function (value, param, options, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n\n // If a file is present in the input\n if (files.length > 0) {\n var defer = jQuery.Deferred();\n\n var file = new FileReader;\n\n // Set up the image validation when the file is loaded\n file.onload = function () {\n var image = new Image;\n\n // Validate once t he image is loaded\n image.onload = function () {\n var width = this.width;\n var height = this.height;\n\n // Check min width, if defined\n if (typeof options.min_width != 'undefined') {\n console.log(width, options.min_width);\n if (width < options.min_width) {\n defer.reject();\n return;\n }\n }\n\n // Check max width, if defined\n if (typeof options.max_width != 'undefined') {\n if (width > options.max_width) {\n defer.reject();\n return;\n }\n }\n\n // Check min height, if defined\n if (typeof options.min_height != 'undefined') {\n if (height < options.min_height) {\n defer.reject();\n return;\n }\n }\n\n // Check max height, if defined\n if (typeof options.max_height != 'undefined') {\n if (height > options.max_height) {\n defer.reject();\n return;\n }\n }\n\n // Check width, if defined\n if (typeof options.width != 'undefined') {\n if (width != options.width) {\n defer.reject();\n return;\n }\n }\n\n // Check height, if defined\n if (typeof options.height != 'undefined') {\n if (height != options.height) {\n defer.reject();\n return;\n }\n }\n\n // Check ratio, if defined\n if (typeof options.ratio != 'undefined') {\n var splitRatio = options.ratio.split(':');\n\n if (splitRatio[0] / splitRatio[1] != width / height) {\n defer.reject();\n return;\n }\n }\n\n defer.resolve();\n };\n\n // On error, reject the promise\n image.onerror = function() {\n console.log('image error');\n defer.reject();\n }\n\n // Set the image\n console.log(file.result);\n image.src = file.result;\n }\n\n // On error, reject the promise\n file.onerror = function() {\n console.log('file error');\n defer.reject();\n }\n\n // Set the file\n console.log(files[0]);\n file.readAsDataURL(files[0])\n\n return defer.promise();\n }\n\n return true;\n }\n });\n\n /**\n * Overwrite core Parsley methods.\n *\n * @type {{_isRequired: Window.ParsleyExtend._isRequired}}\n */\n window.ParsleyExtend = {\n // Normally this was intended Internal only.\n // Field is required if have required constraint without `false` value\n _isRequired: function () {\n\n var requiredRules = [\n // This one comes out of the box with parsley\n 'required',\n\n // These ones were added with this library\n 'requiredIf', 'requiredUnless', 'requiredWith', 'requiredWithAll', 'requiredWithout', 'requiredWithoutAll'\n ];\n\n var requiredRulesFound = [];\n\n // Loop over the list to check if they're defined on the field.\n requiredRules.forEach(function (rule) {\n if ('undefined' !== typeof this.constraintsByName[rule]) {\n requiredRulesFound.push(rule);\n }\n }, this);\n\n // If there's not one required rule, return false\n if (requiredRulesFound.length == 0)\n return false;\n\n // If parsley's on required rule was found\n if (requiredRulesFound.indexOf('required') >= 0) {\n // Check if the flag is set to true\n return false !== this.constraintsByName.required.requirements;\n }\n\n return true;\n }\n };\n\n var main = utils;\n\n return main;\n\n}));\n","// Check if the value is within a comma-separated list (val1,val2,..)\nwindow.Parsley\n .addValidator('in', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n var possibles = parameter.split(',');\n\n return possibles.indexOf(value) > -1;\n },\n messages: {\n en: 'The value should be one of the following: \"%s\".'\n }\n });\n\n// Check if the value is not in a comma-separated list (val1,val2,..)\nwindow.Parsley\n .addValidator('notIn', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n var possibles = parameter.split(',');\n\n return possibles.indexOf(value) == -1;\n },\n messages: {\n en: 'The value should not be one of the following: \"%s\".'\n }\n });","import moment from 'moment';\nimport jQuery from 'jquery';\n\n// Valid date formats\nwindow.Parsley.options.dateFormats = ['DD/MM/YY', 'DD/MM/YYYY', 'MM/DD/YY', 'MM/DD/YYYY', 'YY/MM/DD', 'YYYY/MM/DD'];\n\n// Check if the value is a date\nwindow.Parsley\n .addValidator('date', {\n requirementType: 'boolean',\n validateString: function (value, state, parsleyInstance) {\n return moment(value, formatDatePhpToJs.getDateFormatsOption(parsleyInstance), true).isValid();\n },\n messages: {\n en: 'You should provide a valid date.'\n }\n });\n\n\n// Check if the value is a date in a specific format\nwindow.Parsley\n .addValidator('dateFormat', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n return moment(value, formatDatePhpToJs.convert(parameter), true).isValid();\n },\n messages: {\n en: 'The date you entered is not in the right format (%s).'\n }\n });\n\n\n// Check if the value is a date before the specified date\nwindow.Parsley\n .addValidator('before', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n\n var beforeDate = moment(parameter, dateFormats, true);\n\n // If it's not a valid date, error\n if (beforeDate === false)\n return false;\n\n return moment(value, dateFormats) < beforeDate;\n },\n messages: {\n en: 'The date you entered should be before %s.'\n }\n });\n\n// Check if the value is a date before the specified date (from another input)\nwindow.Parsley\n .addValidator('beforeInput', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var beforeInput = jQuery(parameter);\n\n // If we can't find the input, return true\n if (beforeInput.length == 0)\n return true;\n\n var beforeVal = beforeInput.val();\n\n // If the val is empty, return true\n if (beforeVal == '')\n return true;\n\n var beforeDate = moment(beforeVal, dateFormats, true);\n\n // If the before date isn't valid, error out\n if (beforeDate.isValid() === false) {\n console.warn(parameter + ' input does not contain a valid date');\n return false;\n }\n\n var thisDate = moment(value, dateFormats, true);\n\n // If the value's date isn't valid, error out\n if (thisDate.isValid() === false) {\n console.warn('the input being checked does not contain a valid date');\n return false;\n }\n\n return thisDate < beforeDate;\n },\n messages: {\n en: 'The date you entered should be before %s.'\n }\n });\n\n\n// Check if the value is a date before the specified date\nwindow.Parsley\n .addValidator('after', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var afterDate = moment(parameter, dateFormats, true);\n\n // If it's not a valid date, error\n if (afterDate === false)\n return false;\n\n return moment(value, dateFormats) > afterDate;\n },\n messages: {\n en: 'The date you entered should be after %s.'\n }\n });\n\n// Check if the value is a date before the specified date (from another input)\nwindow.Parsley\n .addValidator('afterInput', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var afterInput = jQuery(parameter);\n\n console.log(this, dateFormats);\n\n // If we can't find the input, return true\n if (afterInput.length == 0)\n return true;\n\n var afterVal = afterInput.val();\n\n // If the val is empty, return true\n if (afterVal == '')\n return true;\n\n var afterDate = moment(afterVal, dateFormats, true);\n\n // If the after date isn't valid, error out\n if (afterDate.isValid() === false) {\n console.warn(parameter + ' input does not contain a valid date');\n return false;\n }\n\n var thisDate = moment(value, dateFormats, true);\n\n // If the value's date isn't valid, error out\n if (thisDate.isValid() === false) {\n console.warn('the input being checked does not contain a valid date');\n return false;\n }\n\n return thisDate > afterDate;\n },\n messages: {\n en: 'The date you entered should be after %s.'\n }\n });\n\n// convert PHP date format to moment JS date format\nvar formatDatePhpToJs = window.formatDatePhpToJs = {\n mapChars: {\n d: 'DD',\n D: 'ddd',\n j: 'D',\n l: 'dddd',\n N: 'E',\n S: function () {\n return '[' + this.format('Do', true).replace(/\\d*/g, '') + ']';\n },\n w: 'd',\n z: function () {\n return this.format('DDD', true) - 1;\n },\n W: 'W',\n F: 'MMMM',\n m: 'MM',\n M: 'MMM',\n n: 'M',\n t: function () {\n return this.daysInMonth();\n },\n L: function () {\n return this.isLeapYear() ? 1 : 0;\n },\n o: 'GGGG',\n Y: 'YYYY',\n y: 'YY',\n a: 'a',\n A: 'A',\n B: function () {\n var thisUTC = this.clone().utc(),\n // Shamelessly stolen from http://javascript.about.com/library/blswatch.htm\n swatch = ((thisUTC.hours() + 1) % 24) + (thisUTC.minutes() / 60) + (thisUTC.seconds() / 3600);\n return Math.floor(swatch * 1000 / 24);\n },\n g: 'h',\n G: 'H',\n h: 'hh',\n H: 'HH',\n i: 'mm',\n s: 'ss',\n u: '[u]', // not sure if moment has this\n e: '[e]', // moment does not have this\n I: function () {\n return this.isDST() ? 1 : 0;\n },\n O: 'ZZ',\n P: 'Z',\n T: '[T]', // deprecated in moment\n Z: function () {\n return parseInt(this.format('ZZ', true), 10) * 36;\n },\n c: 'YYYY-MM-DD[T]HH:mm:ssZ',\n r: 'ddd, DD MMM YYYY HH:mm:ss ZZ',\n U: 'X'\n },\n formatEx: /[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g,\n convert: function (PHPDateFormat) {\n return PHPDateFormat.replace(this.formatEx, function (phpStr) {\n console.log(formatDatePhpToJs.mapChars[phpStr]);\n return typeof formatDatePhpToJs.mapChars[phpStr] === 'function' ? formatDatePhpToJs.mapChars[phpStr].call(moment()) : formatDatePhpToJs.mapChars[phpStr];\n })\n },\n getDateFormatsOption: function (parsleyInstance) {\n if (typeof parsleyInstance.options.dateFormats == 'undefined') {\n return this.getDateFormatsOption(parsleyInstance.parent);\n }\n\n return parsleyInstance.options.dateFormats;\n }\n}","import jQuery from 'jquery';\n\n/**\n * Helper functions.\n *\n * @type {{parseArrayStringParameter: larapars.parseArrayStringParameter, bindChangeToOtherElement: larapars.bindChangeToOtherElement, getDateFormatsOption: larapars.getDateFormatsOption}}\n */\nexport default {\n parseArrayStringParameter: function (parameter) {\n var m = parameter.match(/^\\s*\\[(.*)\\]\\s*$/);\n\n if (!m)\n throw 'Requirement is not an array: \"' + parameter + '\"';\n\n return m[1].replace(/\\'+/g, '').split(',');\n },\n /**\n * This is used by various validation rules that rely on another input for validation.\n *\n * This function adds a 'change' event listener which forces the original to be validated again.\n *\n * @param rule Name of the rule this change handler is for\n * @param element Which element to bind this to\n * @param fieldInstance The ParsleyFieldInstance we can call validate() on\n * @param originalNotEmpty Should the original element not be empty? (optional, default false)\n */\n bindChangeToOtherElement: function (rule, element, fieldInstance, originalNotEmpty) {\n var $elem = jQuery(element);\n var elData = $elem.data('larapars-rules');\n\n // None were added yet, initialise\n if (elData === undefined) {\n elData = [rule];\n $elem.data('larapars-rules', elData);\n }\n // Initialised, but not present\n else if (elData.indexOf(rule) == -1) {\n elData.push(rule);\n $elem.data('larapars-rules', elData);\n }\n // Already bound\n else {\n return;\n }\n\n // If not yet bound\n $elem.on('change', function () {\n if (originalNotEmpty === true && jQuery(fieldInstance.$element.get(0)).val() != '') {\n fieldInstance.validate();\n }\n else if (originalNotEmpty !== true) {\n fieldInstance.validate();\n }\n });\n }\n};","import jQuery from 'jquery';\nimport utils from '../utils.js';\n\n// Check if the value is different from the specified input's value\nwindow.Parsley\n .addValidator('different', {\n requirementType: 'string',\n validateString: function (value, parameter, fieldInstance) {\n if (jQuery(parameter).length == 0)\n return true;\n\n utils.bindChangeToOtherElement('different', parameter, fieldInstance, true);\n\n return jQuery(parameter).val() != value;\n },\n messages: {\n en: 'The value should not be the same as \"%s\".'\n }\n });\n\n// Check if the value is greater than min and smaller than max\nwindow.Parsley\n .addValidator('between', {\n requirementType: ['integer', 'integer'],\n validateNumber: function (value, min, max) {\n return value > min && value < max;\n },\n messages: {\n en: 'The value should be between \"%s\" and \"%s\".'\n }\n });\n\n// Check if the value is equal to the provided value\nwindow.Parsley\n .addValidator('sizeNumber', {\n requirementType: 'integer',\n validateNumber: function (value, parameter) {\n return value == parameter;\n },\n messages: {\n en: 'The value should be \"%s\".'\n }\n });\n\n// Check if the value's length is equal to the provided value\nwindow.Parsley\n .addValidator('sizeString', {\n requirementType: 'integer',\n validateString: function (value, parameter) {\n return value.length == parameter;\n },\n messages: {\n en: 'The value should be \"%s\" characters long.'\n }\n });\n\n\n\n// Check if each value is distinct\nwindow.Parsley\n .addValidator('distinct', {\n requirementType: 'boolean',\n validateMultiple: function (values) {\n var storedValues = [];\n var isDistinct = true;\n\n values.forEach(function (value) {\n if (storedValues.indexOf(value) > -1) {\n isDistinct = false;\n return false;\n }\n\n storedValues.push(value);\n });\n\n return isDistinct;\n },\n messages: {\n en: 'Not all values are distinct.'\n }\n });\n\n\n\n// The value should be located in one of the checkbox's checked values\nwindow.Parsley\n .addValidator('inArray', {\n requirementType: 'string',\n validateString: function (value, otherFieldName, parsleyInstance) {\n var thisElement = jQuery(parsleyInstance.$element.get(0));\n\n var values = [];\n\n // Check if we're dealing with a text field\n if (otherFieldName.substring(0, 1) == '#') {\n // Bind a change event\n utils.bindChangeToOtherElement('inArray', otherFieldName, parsleyInstance, true);\n\n // If it's a text field we're assuming that it's a list of comma separated values\n return jQuery(otherFieldName).val().split(',').indexOf(value) > -1;\n }\n\n // Bind a change handler to the checkboxes\n jQuery('input:checkbox[name=\"' + otherFieldName + '\"]').each(function () {\n utils.bindChangeToOtherElement('inArray', this, parsleyInstance, true);\n });\n\n // Get the selected values of a checkbox by it's name\n jQuery('input:checkbox[name=\"' + otherFieldName + '\"]:checked').each(function () {\n values.push(jQuery(this).val());\n });\n\n // Check if the value is in there\n return values.indexOf(value) > -1;\n },\n messages: {\n en: 'This value is incorrect.'\n }\n });","import jQuery from 'jquery';\nimport utils from '../utils.js';\n\n// The value is required only if another input's value matched one of the defined ones.\n// the parameter should be formatted as data-parsley-required-if=\"[\"#elementValueToCheck\", \"value1,value2,..\"]\"\nwindow.Parsley\n .addValidator('requiredIf', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var values = utils.parseArrayStringParameter(parameters);\n\n // Get the other input's selector\n var field = values[0];\n\n // Get the values it should contain to mark this one as required\n parameters = values.slice(1);\n\n // make sure that the other element get's a change event\n utils.bindChangeToOtherElement('requiredIf', field, fieldInstance);\n\n // Only required to check if the value is empty\n if (value.length == 0) {\n var fieldValue = jQuery(field).val();\n\n return parameters.indexOf(fieldValue) == -1;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n// The value is required if other field does not contain any of the specified values\n// the parameter should be formatted as data-parsley-required-unless=\"[\"#elementValueToCheck\", \"value1,value2,..\"]\"\nwindow.Parsley\n .addValidator('requiredUnless', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var values = utils.parseArrayStringParameter(parameters);\n\n // Get the other input's selector\n var field = values[0];\n\n // Get the values it should contain to mark this one as required\n parameters = values.slice(1);\n\n // make sure that the other element get's a change event\n utils.bindChangeToOtherElement('requiredUnless', field, fieldInstance);\n\n // Only required to check if the value is empty\n if (value.length == 0) {\n\n var fieldValue = jQuery(field).val();\n\n // It's not required if the input has one of the values\n return parameters.indexOf(fieldValue) > -1;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n// The value is required if any of the inputs are present in the dom\n// the parameter should be formatted as data-parsley-required-with=\"#elementValueToCheck,#elementValueToCheck,..\"\nwindow.Parsley\n .addValidator('requiredWith', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AnyPresent = false;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWith', id, fieldInstance);\n\n // If the element is in the dom and has a value\n if ($elem.length > 0 && $elem.val() != '') {\n AnyPresent = true;\n }\n });\n\n return !AnyPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n// The value is required if all other inputs are present in the dom\n// the parameter should be formatted as data-parsley-required-with-all=\"#elementValueToCheck,#elementValueToCheck,..\"\nwindow.Parsley\n .addValidator('requiredWithAll', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AllPresent = true;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n // If the value isn't in the dom or is empty\n if ($elem.length == 0 || $elem.val() == '') {\n AllPresent = false;\n }\n });\n\n return !AllPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n// The value is required if any of the inputs are not present in the dom\n// the parameter should be formatted as data-parsley-required-with=\"#elementValueToCheck,#elementValueToCheck,..\"\nwindow.Parsley\n .addValidator('requiredWithout', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AnyPresent = false;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n if ($elem.length == 0 || $elem.val() == '') {\n AnyPresent = true;\n }\n });\n\n return AnyPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n// The value is required if all other inputs are not present in the dom\n// the parameter should be formatted as data-parsley-required-with-all=\"#elementValueToCheck,#elementValueToCheck,..\"\nwindow.Parsley\n .addValidator('requiredWithoutAll', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AllEmpty = true;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n if ($elem.length == 1 && $elem.val() != '') {\n AllEmpty = false;\n }\n });\n\n return AllEmpty;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });","import jQuery from 'jquery';\nimport utils from '../utils.js';\n\nvar filesSizes = {\n b: 1,\n kb: 1024,\n mb: 1024 * 1024,\n gb: 1024 * 1024 * 1024,\n};\n\n// Make sure all files within the inputs are equal to or smaller than the defined size.\nwindow.Parsley\n .addValidator('fileSizeMax', {\n requirementType: ['integer', 'string'],\n validateString: function (value, maxSize, sizeMultiplyer, parsleyFieldInstance) {\n sizeMultiplyer = sizeMultiplyer.toLowerCase();\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the max file size\n maxSize = maxSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n console.log(maxSize);\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n console.log(files[i].size);\n if (files[i].size > maxSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) are too big.'\n }\n });\n\n\n// Make sure all files within the inputs are equal to or bigger than the defined size.\nwindow.Parsley\n .addValidator('fileSizeMin', {\n requirementType: ['integer', 'string'],\n validateString: function (value, minSize, sizeMultiplyer, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the min file size\n minSize = minSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (files[i].size < minSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) should are too small.'\n }\n });\n\n\n// Make sure all files within the inputs are between the defined sizes.\nwindow.Parsley\n .addValidator('fileSizeBetween', {\n requirementType: ['integer', 'integer', 'string'],\n validateString: function (value, minSize, maxSize, sizeMultiplyer, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the file sizes\n minSize = minSize * filesSizes[sizeMultiplyer.toLowerCase()];\n maxSize = maxSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (files[i].size <= minSize || files[i].size >= maxSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) should be between %s and %s %s.'\n }\n });\n\n\n// Make sure all files within the input are an image\nwindow.Parsley\n .addValidator('image', {\n validateString: function (value, param, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (!files[i].type.match('image/*')) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'This is not an image.'\n }\n });\n\n\n// Make sure all files within the input are an image\nwindow.Parsley\n .addValidator('fileMimetype', {\n requirementType: 'string',\n validateString: function (value, mimetypes, parsleyFieldInstance) {\n var allMimes = utils.parseArrayStringParameter(mimetypes);\n\n var files = parsleyFieldInstance.$element[0].files;\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (allMimes.indexOf(files[i].type) == -1) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'This file does not have the correct mimetype \"%s\".'\n }\n });\n\n// Make sure all images withing the input have specific dimensions\n\n//Parsley.addAsyncValidator();\n\n\nwindow.Parsley\n .addValidator('dimensions', {\n requirementType: {\n '': 'boolean',\n min_width: 'number', // Specify the minimum width the image should have\n max_width: 'number', // Specify the maximum width the image should have\n min_height: 'number', // Specify the minimum height the image should have\n max_height: 'number', // Specify the maximum height the image should have\n width: 'number', // Specify the width the image should have\n height: 'number', // Specify the height the image should have\n ratio: 'string', // Specify the ratio the image should have\n },\n validateString: function (value, param, options, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n\n // If a file is present in the input\n if (files.length > 0) {\n var defer = jQuery.Deferred();\n\n var file = new FileReader;\n\n // Set up the image validation when the file is loaded\n file.onload = function () {\n var image = new Image;\n\n // Validate once t he image is loaded\n image.onload = function () {\n var width = this.width;\n var height = this.height;\n\n // Check min width, if defined\n if (typeof options.min_width != 'undefined') {\n console.log(width, options.min_width);\n if (width < options.min_width) {\n defer.reject();\n return;\n }\n }\n\n // Check max width, if defined\n if (typeof options.max_width != 'undefined') {\n if (width > options.max_width) {\n defer.reject();\n return;\n }\n }\n\n // Check min height, if defined\n if (typeof options.min_height != 'undefined') {\n if (height < options.min_height) {\n defer.reject();\n return;\n }\n }\n\n // Check max height, if defined\n if (typeof options.max_height != 'undefined') {\n if (height > options.max_height) {\n defer.reject();\n return;\n }\n }\n\n // Check width, if defined\n if (typeof options.width != 'undefined') {\n if (width != options.width) {\n defer.reject();\n return;\n }\n }\n\n // Check height, if defined\n if (typeof options.height != 'undefined') {\n if (height != options.height) {\n defer.reject();\n return;\n }\n }\n\n // Check ratio, if defined\n if (typeof options.ratio != 'undefined') {\n var splitRatio = options.ratio.split(':');\n\n if (splitRatio[0] / splitRatio[1] != width / height) {\n defer.reject();\n return;\n }\n }\n\n defer.resolve();\n };\n\n // On error, reject the promise\n image.onerror = function() {\n console.log('image error');\n defer.reject();\n }\n\n // Set the image\n console.log(file.result);\n image.src = file.result;\n }\n\n // On error, reject the promise\n file.onerror = function() {\n console.log('file error');\n defer.reject();\n }\n\n // Set the file\n console.log(files[0]);\n file.readAsDataURL(files[0])\n\n return defer.promise();\n }\n\n return true;\n }\n });","import jQuery from 'jquery';\nimport './rules/ins';\nimport './rules/dates';\nimport './rules/comparison';\nimport './rules/requireds.js';\nimport './rules/files.js';\nimport './utils.js';\n\n/**\n * Overwrite core Parsley methods.\n *\n * @type {{_isRequired: Window.ParsleyExtend._isRequired}}\n */\nwindow.ParsleyExtend = {\n // Normally this was intended Internal only.\n // Field is required if have required constraint without `false` value\n _isRequired: function () {\n\n var requiredRules = [\n // This one comes out of the box with parsley\n 'required',\n\n // These ones were added with this library\n 'requiredIf', 'requiredUnless', 'requiredWith', 'requiredWithAll', 'requiredWithout', 'requiredWithoutAll'\n ];\n\n var requiredRulesFound = [];\n\n // Loop over the list to check if they're defined on the field.\n requiredRules.forEach(function (rule) {\n if ('undefined' !== typeof this.constraintsByName[rule]) {\n requiredRulesFound.push(rule);\n }\n }, this);\n\n // If there's not one required rule, return false\n if (requiredRulesFound.length == 0)\n return false;\n\n // If parsley's on required rule was found\n if (requiredRulesFound.indexOf('required') >= 0) {\n // Check if the flag is set to true\n return false !== this.constraintsByName.required.requirements;\n }\n\n return true;\n }\n};\n\nexport default utils;"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["/source/laravel-parsley.js","/source/src/rules/ins.js","/source/src/rules/dates.js","/source/src/utils.js","/source/src/rules/comparison.js","/source/src/rules/requireds.js","/source/src/rules/files.js","/source/src/main.js"],"names":["global","factory","exports","module","require","define","amd","laraParsley","jQuery","moment","this","window","Parsley","addValidator","requirementType","validateString","value","parameter","possibles","split","indexOf","messages","en","options","dateFormats","state","parsleyInstance","formatDatePhpToJs","getDateFormatsOption","isValid","convert","beforeDate","beforeInput","length","beforeVal","val","console","warn","thisDate","afterDate","afterInput","log","afterVal","mapChars","d","D","j","l","N","S","format","replace","w","z","W","F","m","M","n","t","daysInMonth","L","isLeapYear","o","Y","y","a","A","B","thisUTC","clone","utc","swatch","hours","minutes","seconds","Math","floor","g","G","h","H","i","s","u","e","I","isDST","O","P","T","Z","parseInt","c","r","U","formatEx","PHPDateFormat","phpStr","call","parent","utils","parseArrayStringParameter","match","bindChangeToOtherElement","rule","element","fieldInstance","originalNotEmpty","$elem","elData","data","undefined","push","on","$element","get","validate","validateNumber","min","max","validateMultiple","values","storedValues","isDistinct","forEach","otherFieldName","substring","each","parameters","field","slice","fieldValue","allElements","AnyPresent","id","AllPresent","AllEmpty","filesSizes","b","kb","mb","gb","maxSize","sizeMultiplyer","parsleyFieldInstance","toLowerCase","files","size","minSize","param","type","mimetypes","allMimes","","min_width","max_width","min_height","max_height","width","height","ratio","domOptions","dimensionsOptions","defer","Deferred","_URL","URL","webkitURL","image","Image","onload","reject","splitRatio","resolve","onerror","src","createObjectURL","promise","then","ParsleyExtend","_isRequired","requiredRules","requiredRulesFound","constraintsByName","required","requirements","main"],"mappings":";;;;;;;CAAA,SAAWA,EAAQC,GACI,gBAAZC,UAA0C,mBAAXC,QAAyBA,OAAOD,QAAUD,EAAQG,QAAQ,UAAWA,QAAQ,WACjG,kBAAXC,SAAyBA,OAAOC,IAAMD,QAAQ,SAAU,UAAWJ,GAC1ED,EAAOO,YAAcN,EAAQD,EAAOQ,OAAQR,EAAOS,SACrDC,KAAM,SAAUF,EAAQC,GAAU,YCHpCE,QAAOC,QACFC,aAAa,MACVC,gBAAiB,SACjBC,eAAgB,SAAUC,EAAOC,GAC7B,GAAIC,GAAYD,EAAUE,MAAM,IAEhC,OAAOD,GAAUE,QAAQJ,GAAS,IAEtCK,UACIC,GAAI,qDAKhBX,OAAOC,QACFC,aAAa,SACVC,gBAAiB,SACjBC,eAAgB,SAAUC,EAAOC,GAC7B,GAAIC,GAAYD,EAAUE,MAAM,IAEhC,OAAmC,IAA5BD,EAAUE,QAAQJ,IAE7BK,UACIC,G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esContent":["(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('moment')) :\n typeof define === 'function' && define.amd ? define(['jquery', 'moment'], factory) :\n global.laraParsley = factory(global.jQuery, global.moment)\n}(this, function (jQuery, moment) { 'use strict';\n\n // Check if the value is within a comma-separated list (val1,val2,..)\n window.Parsley\n .addValidator('in', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n var possibles = parameter.split(',');\n\n return possibles.indexOf(value) > -1;\n },\n messages: {\n en: 'The value should be one of the following: \"%s\".'\n }\n });\n\n // Check if the value is not in a comma-separated list (val1,val2,..)\n window.Parsley\n .addValidator('notIn', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n var possibles = parameter.split(',');\n\n return possibles.indexOf(value) == -1;\n },\n messages: {\n en: 'The value should not be one of the following: \"%s\".'\n }\n });\n\n // Valid date formats\n window.Parsley.options.dateFormats = ['DD/MM/YY', 'DD/MM/YYYY', 'MM/DD/YY', 'MM/DD/YYYY', 'YY/MM/DD', 'YYYY/MM/DD'];\n\n // Check if the value is a date\n window.Parsley\n .addValidator('date', {\n requirementType: 'boolean',\n validateString: function (value, state, parsleyInstance) {\n return moment(value, formatDatePhpToJs.getDateFormatsOption(parsleyInstance), true).isValid();\n },\n messages: {\n en: 'You should provide a valid date.'\n }\n });\n\n\n // Check if the value is a date in a specific format\n window.Parsley\n .addValidator('dateFormat', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n return moment(value, formatDatePhpToJs.convert(parameter), true).isValid();\n },\n messages: {\n en: 'The date you entered is not in the right format (%s).'\n }\n });\n\n\n // Check if the value is a date before the specified date\n window.Parsley\n .addValidator('before', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n\n var beforeDate = moment(parameter, dateFormats, true);\n\n // If it's not a valid date, error\n if (beforeDate === false)\n return false;\n\n return moment(value, dateFormats) < beforeDate;\n },\n messages: {\n en: 'The date you entered should be before %s.'\n }\n });\n\n // Check if the value is a date before the specified date (from another input)\n window.Parsley\n .addValidator('beforeInput', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var beforeInput = jQuery(parameter);\n\n // If we can't find the input, return true\n if (beforeInput.length == 0)\n return true;\n\n var beforeVal = beforeInput.val();\n\n // If the val is empty, return true\n if (beforeVal == '')\n return true;\n\n var beforeDate = moment(beforeVal, dateFormats, true);\n\n // If the before date isn't valid, error out\n if (beforeDate.isValid() === false) {\n console.warn(parameter + ' input does not contain a valid date');\n return false;\n }\n\n var thisDate = moment(value, dateFormats, true);\n\n // If the value's date isn't valid, error out\n if (thisDate.isValid() === false) {\n console.warn('the input being checked does not contain a valid date');\n return false;\n }\n\n return thisDate < beforeDate;\n },\n messages: {\n en: 'The date you entered should be before %s.'\n }\n });\n\n\n // Check if the value is a date before the specified date\n window.Parsley\n .addValidator('after', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var afterDate = moment(parameter, dateFormats, true);\n\n // If it's not a valid date, error\n if (afterDate === false)\n return false;\n\n return moment(value, dateFormats) > afterDate;\n },\n messages: {\n en: 'The date you entered should be after %s.'\n }\n });\n\n // Check if the value is a date before the specified date (from another input)\n window.Parsley\n .addValidator('afterInput', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var afterInput = jQuery(parameter);\n\n console.log(this, dateFormats);\n\n // If we can't find the input, return true\n if (afterInput.length == 0)\n return true;\n\n var afterVal = afterInput.val();\n\n // If the val is empty, return true\n if (afterVal == '')\n return true;\n\n var afterDate = moment(afterVal, dateFormats, true);\n\n // If the after date isn't valid, error out\n if (afterDate.isValid() === false) {\n console.warn(parameter + ' input does not contain a valid date');\n return false;\n }\n\n var thisDate = moment(value, dateFormats, true);\n\n // If the value's date isn't valid, error out\n if (thisDate.isValid() === false) {\n console.warn('the input being checked does not contain a valid date');\n return false;\n }\n\n return thisDate > afterDate;\n },\n messages: {\n en: 'The date you entered should be after %s.'\n }\n });\n\n // convert PHP date format to moment JS date format\n var formatDatePhpToJs = window.formatDatePhpToJs = {\n mapChars: {\n d: 'DD',\n D: 'ddd',\n j: 'D',\n l: 'dddd',\n N: 'E',\n S: function () {\n return '[' + this.format('Do', true).replace(/\\d*/g, '') + ']';\n },\n w: 'd',\n z: function () {\n return this.format('DDD', true) - 1;\n },\n W: 'W',\n F: 'MMMM',\n m: 'MM',\n M: 'MMM',\n n: 'M',\n t: function () {\n return this.daysInMonth();\n },\n L: function () {\n return this.isLeapYear() ? 1 : 0;\n },\n o: 'GGGG',\n Y: 'YYYY',\n y: 'YY',\n a: 'a',\n A: 'A',\n B: function () {\n var thisUTC = this.clone().utc(),\n // Shamelessly stolen from http://javascript.about.com/library/blswatch.htm\n swatch = ((thisUTC.hours() + 1) % 24) + (thisUTC.minutes() / 60) + (thisUTC.seconds() / 3600);\n return Math.floor(swatch * 1000 / 24);\n },\n g: 'h',\n G: 'H',\n h: 'hh',\n H: 'HH',\n i: 'mm',\n s: 'ss',\n u: '[u]', // not sure if moment has this\n e: '[e]', // moment does not have this\n I: function () {\n return this.isDST() ? 1 : 0;\n },\n O: 'ZZ',\n P: 'Z',\n T: '[T]', // deprecated in moment\n Z: function () {\n return parseInt(this.format('ZZ', true), 10) * 36;\n },\n c: 'YYYY-MM-DD[T]HH:mm:ssZ',\n r: 'ddd, DD MMM YYYY HH:mm:ss ZZ',\n U: 'X'\n },\n formatEx: /[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g,\n convert: function (PHPDateFormat) {\n return PHPDateFormat.replace(this.formatEx, function (phpStr) {\n console.log(formatDatePhpToJs.mapChars[phpStr]);\n return typeof formatDatePhpToJs.mapChars[phpStr] === 'function' ? formatDatePhpToJs.mapChars[phpStr].call(moment()) : formatDatePhpToJs.mapChars[phpStr];\n })\n },\n getDateFormatsOption: function (parsleyInstance) {\n if (typeof parsleyInstance.options.dateFormats == 'undefined') {\n return this.getDateFormatsOption(parsleyInstance.parent);\n }\n\n return parsleyInstance.options.dateFormats;\n }\n }\n\n /**\n * Helper functions.\n *\n * @type {{parseArrayStringParameter: larapars.parseArrayStringParameter, bindChangeToOtherElement: larapars.bindChangeToOtherElement, getDateFormatsOption: larapars.getDateFormatsOption}}\n */\n var utils = {\n parseArrayStringParameter: function (parameter) {\n var m = parameter.match(/^\\s*\\[(.*)\\]\\s*$/);\n\n if (!m)\n throw 'Requirement is not an array: \"' + parameter + '\"';\n\n return m[1].replace(/\\'+/g, '').split(',');\n },\n /**\n * This is used by various validation rules that rely on another input for validation.\n *\n * This function adds a 'change' event listener which forces the original to be validated again.\n *\n * @param rule Name of the rule this change handler is for\n * @param element Which element to bind this to\n * @param fieldInstance The ParsleyFieldInstance we can call validate() on\n * @param originalNotEmpty Should the original element not be empty? (optional, default false)\n */\n bindChangeToOtherElement: function (rule, element, fieldInstance, originalNotEmpty) {\n var $elem = jQuery(element);\n var elData = $elem.data('larapars-rules');\n\n // None were added yet, initialise\n if (elData === undefined) {\n elData = [rule];\n $elem.data('larapars-rules', elData);\n }\n // Initialised, but not present\n else if (elData.indexOf(rule) == -1) {\n elData.push(rule);\n $elem.data('larapars-rules', elData);\n }\n // Already bound\n else {\n return;\n }\n\n // If not yet bound\n $elem.on('change', function () {\n if (originalNotEmpty === true && jQuery(fieldInstance.$element.get(0)).val() != '') {\n fieldInstance.validate();\n }\n else if (originalNotEmpty !== true) {\n fieldInstance.validate();\n }\n });\n }\n };\n\n // Check if the value is different from the specified input's value\n window.Parsley\n .addValidator('different', {\n requirementType: 'string',\n validateString: function (value, parameter, fieldInstance) {\n if (jQuery(parameter).length == 0)\n return true;\n\n utils.bindChangeToOtherElement('different', parameter, fieldInstance, true);\n\n return jQuery(parameter).val() != value;\n },\n messages: {\n en: 'The value should not be the same as \"%s\".'\n }\n });\n\n // Check if the value is greater than min and smaller than max\n window.Parsley\n .addValidator('between', {\n requirementType: ['integer', 'integer'],\n validateNumber: function (value, min, max) {\n return value > min && value < max;\n },\n messages: {\n en: 'The value should be between \"%s\" and \"%s\".'\n }\n });\n\n // Check if the value is equal to the provided value\n window.Parsley\n .addValidator('sizeNumber', {\n requirementType: 'integer',\n validateNumber: function (value, parameter) {\n return value == parameter;\n },\n messages: {\n en: 'The value should be \"%s\".'\n }\n });\n\n // Check if the value's length is equal to the provided value\n window.Parsley\n .addValidator('sizeString', {\n requirementType: 'integer',\n validateString: function (value, parameter) {\n return value.length == parameter;\n },\n messages: {\n en: 'The value should be \"%s\" characters long.'\n }\n });\n\n\n\n // Check if each value is distinct\n window.Parsley\n .addValidator('distinct', {\n requirementType: 'boolean',\n validateMultiple: function (values) {\n var storedValues = [];\n var isDistinct = true;\n\n values.forEach(function (value) {\n if (storedValues.indexOf(value) > -1) {\n isDistinct = false;\n return false;\n }\n\n storedValues.push(value);\n });\n\n return isDistinct;\n },\n messages: {\n en: 'Not all values are distinct.'\n }\n });\n\n\n\n // The value should be located in one of the checkbox's checked values\n window.Parsley\n .addValidator('inArray', {\n requirementType: 'string',\n validateString: function (value, otherFieldName, parsleyInstance) {\n var thisElement = jQuery(parsleyInstance.$element.get(0));\n\n var values = [];\n\n // Check if we're dealing with a text field\n if (otherFieldName.substring(0, 1) == '#') {\n // Bind a change event\n utils.bindChangeToOtherElement('inArray', otherFieldName, parsleyInstance, true);\n\n // If it's a text field we're assuming that it's a list of comma separated values\n return jQuery(otherFieldName).val().split(',').indexOf(value) > -1;\n }\n\n // Bind a change handler to the checkboxes\n jQuery('input:checkbox[name=\"' + otherFieldName + '\"]').each(function () {\n utils.bindChangeToOtherElement('inArray', this, parsleyInstance, true);\n });\n\n // Get the selected values of a checkbox by it's name\n jQuery('input:checkbox[name=\"' + otherFieldName + '\"]:checked').each(function () {\n values.push(jQuery(this).val());\n });\n\n // Check if the value is in there\n return values.indexOf(value) > -1;\n },\n messages: {\n en: 'This value is incorrect.'\n }\n });\n\n // The value is required only if another input's value matched one of the defined ones.\n // the parameter should be formatted as data-parsley-required-if=\"[\"#elementValueToCheck\", \"value1,value2,..\"]\"\n window.Parsley\n .addValidator('requiredIf', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var values = utils.parseArrayStringParameter(parameters);\n\n // Get the other input's selector\n var field = values[0];\n\n // Get the values it should contain to mark this one as required\n parameters = values.slice(1);\n\n // make sure that the other element get's a change event\n utils.bindChangeToOtherElement('requiredIf', field, fieldInstance);\n\n // Only required to check if the value is empty\n if (value.length == 0) {\n var fieldValue = jQuery(field).val();\n\n return parameters.indexOf(fieldValue) == -1;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n // The value is required if other field does not contain any of the specified values\n // the parameter should be formatted as data-parsley-required-unless=\"[\"#elementValueToCheck\", \"value1,value2,..\"]\"\n window.Parsley\n .addValidator('requiredUnless', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var values = utils.parseArrayStringParameter(parameters);\n\n // Get the other input's selector\n var field = values[0];\n\n // Get the values it should contain to mark this one as required\n parameters = values.slice(1);\n\n // make sure that the other element get's a change event\n utils.bindChangeToOtherElement('requiredUnless', field, fieldInstance);\n\n // Only required to check if the value is empty\n if (value.length == 0) {\n\n var fieldValue = jQuery(field).val();\n\n // It's not required if the input has one of the values\n return parameters.indexOf(fieldValue) > -1;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n // The value is required if any of the inputs are present in the dom\n // the parameter should be formatted as data-parsley-required-with=\"#elementValueToCheck,#elementValueToCheck,..\"\n window.Parsley\n .addValidator('requiredWith', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AnyPresent = false;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWith', id, fieldInstance);\n\n // If the element is in the dom and has a value\n if ($elem.length > 0 && $elem.val() != '') {\n AnyPresent = true;\n }\n });\n\n return !AnyPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n // The value is required if all other inputs are present in the dom\n // the parameter should be formatted as data-parsley-required-with-all=\"#elementValueToCheck,#elementValueToCheck,..\"\n window.Parsley\n .addValidator('requiredWithAll', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AllPresent = true;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n // If the value isn't in the dom or is empty\n if ($elem.length == 0 || $elem.val() == '') {\n AllPresent = false;\n }\n });\n\n return !AllPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n // The value is required if any of the inputs are not present in the dom\n // the parameter should be formatted as data-parsley-required-with=\"#elementValueToCheck,#elementValueToCheck,..\"\n window.Parsley\n .addValidator('requiredWithout', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AnyPresent = false;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n if ($elem.length == 0 || $elem.val() == '') {\n AnyPresent = true;\n }\n });\n\n return AnyPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n // The value is required if all other inputs are not present in the dom\n // the parameter should be formatted as data-parsley-required-with-all=\"#elementValueToCheck,#elementValueToCheck,..\"\n window.Parsley\n .addValidator('requiredWithoutAll', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AllEmpty = true;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n if ($elem.length == 1 && $elem.val() != '') {\n AllEmpty = false;\n }\n });\n\n return AllEmpty;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n var filesSizes = {\n b: 1,\n kb: 1024,\n mb: 1024 * 1024,\n gb: 1024 * 1024 * 1024,\n };\n\n // Make sure all files within the inputs are equal to or smaller than the defined size.\n window.Parsley\n .addValidator('fileSizeMax', {\n requirementType: ['integer', 'string'],\n validateString: function (value, maxSize, sizeMultiplyer, parsleyFieldInstance) {\n sizeMultiplyer = sizeMultiplyer.toLowerCase();\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the max file size\n maxSize = maxSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n console.log(maxSize);\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n console.log(files[i].size);\n if (files[i].size > maxSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) are too big.'\n }\n });\n\n\n // Make sure all files within the inputs are equal to or bigger than the defined size.\n window.Parsley\n .addValidator('fileSizeMin', {\n requirementType: ['integer', 'string'],\n validateString: function (value, minSize, sizeMultiplyer, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the min file size\n minSize = minSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (files[i].size < minSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) should are too small.'\n }\n });\n\n\n // Make sure all files within the inputs are between the defined sizes.\n window.Parsley\n .addValidator('fileSizeBetween', {\n requirementType: ['integer', 'integer', 'string'],\n validateString: function (value, minSize, maxSize, sizeMultiplyer, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the file sizes\n minSize = minSize * filesSizes[sizeMultiplyer.toLowerCase()];\n maxSize = maxSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (files[i].size <= minSize || files[i].size >= maxSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) should be between %s and %s %s.'\n }\n });\n\n\n // Make sure all files within the input are an image\n window.Parsley\n .addValidator('image', {\n validateString: function (value, param, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (!files[i].type.match('image/*')) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'This is not an image.'\n }\n });\n\n\n // Make sure all files within the input are an image\n window.Parsley\n .addValidator('fileMimetype', {\n requirementType: 'string',\n validateString: function (value, mimetypes, parsleyFieldInstance) {\n var allMimes = utils.parseArrayStringParameter(mimetypes);\n\n var files = parsleyFieldInstance.$element[0].files;\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (allMimes.indexOf(files[i].type) == -1) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'This file does not have the correct mimetype \"%s\".'\n }\n });\n\n // Make sure all images withing the input have specific dimensions\n window.Parsley\n .addValidator('dimensions', {\n requirementType: {\n '': 'boolean',\n min_width: 'number', // Specify the minimum width the image should have\n max_width: 'number', // Specify the maximum width the image should have\n min_height: 'number', // Specify the minimum height the image should have\n max_height: 'number', // Specify the maximum height the image should have\n width: 'number', // Specify the width the image should have\n height: 'number', // Specify the height the image should have\n ratio: 'string', // Specify the ratio the image should have\n },\n validateString: function (value, param, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n var options = parsleyFieldInstance.domOptions.dimensionsOptions;\n\n // If a file is present in the input\n if (files.length > 0) {\n var defer = jQuery.Deferred();\n var _URL = window.URL || window.webkitURL;\n\n var image = new Image;\n\n // Validate once t he image is loaded\n image.onload = function () {\n var width = this.width;\n var height = this.height;\n\n // Check min width, if defined\n if (typeof options.min_width != 'undefined') {\n if (width < options.min_width) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check max width, if defined\n if (typeof options.max_width != 'undefined') {\n if (width > options.max_width) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check min height, if defined\n if (typeof options.min_height != 'undefined') {\n if (height < options.min_height) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check max height, if defined\n if (typeof options.max_height != 'undefined') {\n if (height > options.max_height) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check width, if defined\n if (typeof options.width != 'undefined') {\n if (width != options.width) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check height, if defined\n if (typeof options.height != 'undefined') {\n if (height != options.height) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check ratio, if defined\n if (typeof options.ratio != 'undefined') {\n var splitRatio = options.ratio.split(':');\n if (splitRatio[0] / splitRatio[1] != width / height) {\n defer.reject(image);\n return true;\n }\n }\n\n defer.resolve(image);\n };\n\n // On error, reject the promise\n image.onerror = function () {\n console.warn('image load error');\n defer.reject();\n }\n\n image.src = _URL.createObjectURL(files[0]);\n\n return defer.promise().then(function(image){\n // Clean up\n image = null;\n\n return true;\n }, function(image){\n // Clean up\n image = null;\n\n return false;\n });\n }\n\n return true;\n }\n });\n\n /**\n * Overwrite core Parsley methods.\n *\n * @type {{_isRequired: Window.ParsleyExtend._isRequired}}\n */\n window.ParsleyExtend = {\n // Normally this was intended Internal only.\n // Field is required if have required constraint without `false` value\n _isRequired: function () {\n\n var requiredRules = [\n // This one comes out of the box with parsley\n 'required',\n\n // These ones were added with this library\n 'requiredIf', 'requiredUnless', 'requiredWith', 'requiredWithAll', 'requiredWithout', 'requiredWithoutAll'\n ];\n\n var requiredRulesFound = [];\n\n // Loop over the list to check if they're defined on the field.\n requiredRules.forEach(function (rule) {\n if ('undefined' !== typeof this.constraintsByName[rule]) {\n requiredRulesFound.push(rule);\n }\n }, this);\n\n // If there's not one required rule, return false\n if (requiredRulesFound.length == 0)\n return false;\n\n // If parsley's on required rule was found\n if (requiredRulesFound.indexOf('required') >= 0) {\n // Check if the flag is set to true\n return false !== this.constraintsByName.required.requirements;\n }\n\n return true;\n }\n };\n\n var main = utils;\n\n return main;\n\n}));\n","// Check if the value is within a comma-separated list (val1,val2,..)\nwindow.Parsley\n .addValidator('in', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n var possibles = parameter.split(',');\n\n return possibles.indexOf(value) > -1;\n },\n messages: {\n en: 'The value should be one of the following: \"%s\".'\n }\n });\n\n// Check if the value is not in a comma-separated list (val1,val2,..)\nwindow.Parsley\n .addValidator('notIn', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n var possibles = parameter.split(',');\n\n return possibles.indexOf(value) == -1;\n },\n messages: {\n en: 'The value should not be one of the following: \"%s\".'\n }\n });","import moment from 'moment';\nimport jQuery from 'jquery';\n\n// Valid date formats\nwindow.Parsley.options.dateFormats = ['DD/MM/YY', 'DD/MM/YYYY', 'MM/DD/YY', 'MM/DD/YYYY', 'YY/MM/DD', 'YYYY/MM/DD'];\n\n// Check if the value is a date\nwindow.Parsley\n .addValidator('date', {\n requirementType: 'boolean',\n validateString: function (value, state, parsleyInstance) {\n return moment(value, formatDatePhpToJs.getDateFormatsOption(parsleyInstance), true).isValid();\n },\n messages: {\n en: 'You should provide a valid date.'\n }\n });\n\n\n// Check if the value is a date in a specific format\nwindow.Parsley\n .addValidator('dateFormat', {\n requirementType: 'string',\n validateString: function (value, parameter) {\n return moment(value, formatDatePhpToJs.convert(parameter), true).isValid();\n },\n messages: {\n en: 'The date you entered is not in the right format (%s).'\n }\n });\n\n\n// Check if the value is a date before the specified date\nwindow.Parsley\n .addValidator('before', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n\n var beforeDate = moment(parameter, dateFormats, true);\n\n // If it's not a valid date, error\n if (beforeDate === false)\n return false;\n\n return moment(value, dateFormats) < beforeDate;\n },\n messages: {\n en: 'The date you entered should be before %s.'\n }\n });\n\n// Check if the value is a date before the specified date (from another input)\nwindow.Parsley\n .addValidator('beforeInput', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var beforeInput = jQuery(parameter);\n\n // If we can't find the input, return true\n if (beforeInput.length == 0)\n return true;\n\n var beforeVal = beforeInput.val();\n\n // If the val is empty, return true\n if (beforeVal == '')\n return true;\n\n var beforeDate = moment(beforeVal, dateFormats, true);\n\n // If the before date isn't valid, error out\n if (beforeDate.isValid() === false) {\n console.warn(parameter + ' input does not contain a valid date');\n return false;\n }\n\n var thisDate = moment(value, dateFormats, true);\n\n // If the value's date isn't valid, error out\n if (thisDate.isValid() === false) {\n console.warn('the input being checked does not contain a valid date');\n return false;\n }\n\n return thisDate < beforeDate;\n },\n messages: {\n en: 'The date you entered should be before %s.'\n }\n });\n\n\n// Check if the value is a date before the specified date\nwindow.Parsley\n .addValidator('after', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var afterDate = moment(parameter, dateFormats, true);\n\n // If it's not a valid date, error\n if (afterDate === false)\n return false;\n\n return moment(value, dateFormats) > afterDate;\n },\n messages: {\n en: 'The date you entered should be after %s.'\n }\n });\n\n// Check if the value is a date before the specified date (from another input)\nwindow.Parsley\n .addValidator('afterInput', {\n requirementType: 'string',\n validateString: function (value, parameter, parsleyInstance) {\n var dateFormats = formatDatePhpToJs.getDateFormatsOption(parsleyInstance);\n var afterInput = jQuery(parameter);\n\n console.log(this, dateFormats);\n\n // If we can't find the input, return true\n if (afterInput.length == 0)\n return true;\n\n var afterVal = afterInput.val();\n\n // If the val is empty, return true\n if (afterVal == '')\n return true;\n\n var afterDate = moment(afterVal, dateFormats, true);\n\n // If the after date isn't valid, error out\n if (afterDate.isValid() === false) {\n console.warn(parameter + ' input does not contain a valid date');\n return false;\n }\n\n var thisDate = moment(value, dateFormats, true);\n\n // If the value's date isn't valid, error out\n if (thisDate.isValid() === false) {\n console.warn('the input being checked does not contain a valid date');\n return false;\n }\n\n return thisDate > afterDate;\n },\n messages: {\n en: 'The date you entered should be after %s.'\n }\n });\n\n// convert PHP date format to moment JS date format\nvar formatDatePhpToJs = window.formatDatePhpToJs = {\n mapChars: {\n d: 'DD',\n D: 'ddd',\n j: 'D',\n l: 'dddd',\n N: 'E',\n S: function () {\n return '[' + this.format('Do', true).replace(/\\d*/g, '') + ']';\n },\n w: 'd',\n z: function () {\n return this.format('DDD', true) - 1;\n },\n W: 'W',\n F: 'MMMM',\n m: 'MM',\n M: 'MMM',\n n: 'M',\n t: function () {\n return this.daysInMonth();\n },\n L: function () {\n return this.isLeapYear() ? 1 : 0;\n },\n o: 'GGGG',\n Y: 'YYYY',\n y: 'YY',\n a: 'a',\n A: 'A',\n B: function () {\n var thisUTC = this.clone().utc(),\n // Shamelessly stolen from http://javascript.about.com/library/blswatch.htm\n swatch = ((thisUTC.hours() + 1) % 24) + (thisUTC.minutes() / 60) + (thisUTC.seconds() / 3600);\n return Math.floor(swatch * 1000 / 24);\n },\n g: 'h',\n G: 'H',\n h: 'hh',\n H: 'HH',\n i: 'mm',\n s: 'ss',\n u: '[u]', // not sure if moment has this\n e: '[e]', // moment does not have this\n I: function () {\n return this.isDST() ? 1 : 0;\n },\n O: 'ZZ',\n P: 'Z',\n T: '[T]', // deprecated in moment\n Z: function () {\n return parseInt(this.format('ZZ', true), 10) * 36;\n },\n c: 'YYYY-MM-DD[T]HH:mm:ssZ',\n r: 'ddd, DD MMM YYYY HH:mm:ss ZZ',\n U: 'X'\n },\n formatEx: /[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g,\n convert: function (PHPDateFormat) {\n return PHPDateFormat.replace(this.formatEx, function (phpStr) {\n console.log(formatDatePhpToJs.mapChars[phpStr]);\n return typeof formatDatePhpToJs.mapChars[phpStr] === 'function' ? formatDatePhpToJs.mapChars[phpStr].call(moment()) : formatDatePhpToJs.mapChars[phpStr];\n })\n },\n getDateFormatsOption: function (parsleyInstance) {\n if (typeof parsleyInstance.options.dateFormats == 'undefined') {\n return this.getDateFormatsOption(parsleyInstance.parent);\n }\n\n return parsleyInstance.options.dateFormats;\n }\n}","import jQuery from 'jquery';\n\n/**\n * Helper functions.\n *\n * @type {{parseArrayStringParameter: larapars.parseArrayStringParameter, bindChangeToOtherElement: larapars.bindChangeToOtherElement, getDateFormatsOption: larapars.getDateFormatsOption}}\n */\nexport default {\n parseArrayStringParameter: function (parameter) {\n var m = parameter.match(/^\\s*\\[(.*)\\]\\s*$/);\n\n if (!m)\n throw 'Requirement is not an array: \"' + parameter + '\"';\n\n return m[1].replace(/\\'+/g, '').split(',');\n },\n /**\n * This is used by various validation rules that rely on another input for validation.\n *\n * This function adds a 'change' event listener which forces the original to be validated again.\n *\n * @param rule Name of the rule this change handler is for\n * @param element Which element to bind this to\n * @param fieldInstance The ParsleyFieldInstance we can call validate() on\n * @param originalNotEmpty Should the original element not be empty? (optional, default false)\n */\n bindChangeToOtherElement: function (rule, element, fieldInstance, originalNotEmpty) {\n var $elem = jQuery(element);\n var elData = $elem.data('larapars-rules');\n\n // None were added yet, initialise\n if (elData === undefined) {\n elData = [rule];\n $elem.data('larapars-rules', elData);\n }\n // Initialised, but not present\n else if (elData.indexOf(rule) == -1) {\n elData.push(rule);\n $elem.data('larapars-rules', elData);\n }\n // Already bound\n else {\n return;\n }\n\n // If not yet bound\n $elem.on('change', function () {\n if (originalNotEmpty === true && jQuery(fieldInstance.$element.get(0)).val() != '') {\n fieldInstance.validate();\n }\n else if (originalNotEmpty !== true) {\n fieldInstance.validate();\n }\n });\n }\n};","import jQuery from 'jquery';\nimport utils from '../utils.js';\n\n// Check if the value is different from the specified input's value\nwindow.Parsley\n .addValidator('different', {\n requirementType: 'string',\n validateString: function (value, parameter, fieldInstance) {\n if (jQuery(parameter).length == 0)\n return true;\n\n utils.bindChangeToOtherElement('different', parameter, fieldInstance, true);\n\n return jQuery(parameter).val() != value;\n },\n messages: {\n en: 'The value should not be the same as \"%s\".'\n }\n });\n\n// Check if the value is greater than min and smaller than max\nwindow.Parsley\n .addValidator('between', {\n requirementType: ['integer', 'integer'],\n validateNumber: function (value, min, max) {\n return value > min && value < max;\n },\n messages: {\n en: 'The value should be between \"%s\" and \"%s\".'\n }\n });\n\n// Check if the value is equal to the provided value\nwindow.Parsley\n .addValidator('sizeNumber', {\n requirementType: 'integer',\n validateNumber: function (value, parameter) {\n return value == parameter;\n },\n messages: {\n en: 'The value should be \"%s\".'\n }\n });\n\n// Check if the value's length is equal to the provided value\nwindow.Parsley\n .addValidator('sizeString', {\n requirementType: 'integer',\n validateString: function (value, parameter) {\n return value.length == parameter;\n },\n messages: {\n en: 'The value should be \"%s\" characters long.'\n }\n });\n\n\n\n// Check if each value is distinct\nwindow.Parsley\n .addValidator('distinct', {\n requirementType: 'boolean',\n validateMultiple: function (values) {\n var storedValues = [];\n var isDistinct = true;\n\n values.forEach(function (value) {\n if (storedValues.indexOf(value) > -1) {\n isDistinct = false;\n return false;\n }\n\n storedValues.push(value);\n });\n\n return isDistinct;\n },\n messages: {\n en: 'Not all values are distinct.'\n }\n });\n\n\n\n// The value should be located in one of the checkbox's checked values\nwindow.Parsley\n .addValidator('inArray', {\n requirementType: 'string',\n validateString: function (value, otherFieldName, parsleyInstance) {\n var thisElement = jQuery(parsleyInstance.$element.get(0));\n\n var values = [];\n\n // Check if we're dealing with a text field\n if (otherFieldName.substring(0, 1) == '#') {\n // Bind a change event\n utils.bindChangeToOtherElement('inArray', otherFieldName, parsleyInstance, true);\n\n // If it's a text field we're assuming that it's a list of comma separated values\n return jQuery(otherFieldName).val().split(',').indexOf(value) > -1;\n }\n\n // Bind a change handler to the checkboxes\n jQuery('input:checkbox[name=\"' + otherFieldName + '\"]').each(function () {\n utils.bindChangeToOtherElement('inArray', this, parsleyInstance, true);\n });\n\n // Get the selected values of a checkbox by it's name\n jQuery('input:checkbox[name=\"' + otherFieldName + '\"]:checked').each(function () {\n values.push(jQuery(this).val());\n });\n\n // Check if the value is in there\n return values.indexOf(value) > -1;\n },\n messages: {\n en: 'This value is incorrect.'\n }\n });","import jQuery from 'jquery';\nimport utils from '../utils.js';\n\n// The value is required only if another input's value matched one of the defined ones.\n// the parameter should be formatted as data-parsley-required-if=\"[\"#elementValueToCheck\", \"value1,value2,..\"]\"\nwindow.Parsley\n .addValidator('requiredIf', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var values = utils.parseArrayStringParameter(parameters);\n\n // Get the other input's selector\n var field = values[0];\n\n // Get the values it should contain to mark this one as required\n parameters = values.slice(1);\n\n // make sure that the other element get's a change event\n utils.bindChangeToOtherElement('requiredIf', field, fieldInstance);\n\n // Only required to check if the value is empty\n if (value.length == 0) {\n var fieldValue = jQuery(field).val();\n\n return parameters.indexOf(fieldValue) == -1;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n// The value is required if other field does not contain any of the specified values\n// the parameter should be formatted as data-parsley-required-unless=\"[\"#elementValueToCheck\", \"value1,value2,..\"]\"\nwindow.Parsley\n .addValidator('requiredUnless', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var values = utils.parseArrayStringParameter(parameters);\n\n // Get the other input's selector\n var field = values[0];\n\n // Get the values it should contain to mark this one as required\n parameters = values.slice(1);\n\n // make sure that the other element get's a change event\n utils.bindChangeToOtherElement('requiredUnless', field, fieldInstance);\n\n // Only required to check if the value is empty\n if (value.length == 0) {\n\n var fieldValue = jQuery(field).val();\n\n // It's not required if the input has one of the values\n return parameters.indexOf(fieldValue) > -1;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n// The value is required if any of the inputs are present in the dom\n// the parameter should be formatted as data-parsley-required-with=\"#elementValueToCheck,#elementValueToCheck,..\"\nwindow.Parsley\n .addValidator('requiredWith', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AnyPresent = false;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWith', id, fieldInstance);\n\n // If the element is in the dom and has a value\n if ($elem.length > 0 && $elem.val() != '') {\n AnyPresent = true;\n }\n });\n\n return !AnyPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n// The value is required if all other inputs are present in the dom\n// the parameter should be formatted as data-parsley-required-with-all=\"#elementValueToCheck,#elementValueToCheck,..\"\nwindow.Parsley\n .addValidator('requiredWithAll', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AllPresent = true;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n // If the value isn't in the dom or is empty\n if ($elem.length == 0 || $elem.val() == '') {\n AllPresent = false;\n }\n });\n\n return !AllPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n// The value is required if any of the inputs are not present in the dom\n// the parameter should be formatted as data-parsley-required-with=\"#elementValueToCheck,#elementValueToCheck,..\"\nwindow.Parsley\n .addValidator('requiredWithout', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AnyPresent = false;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n if ($elem.length == 0 || $elem.val() == '') {\n AnyPresent = true;\n }\n });\n\n return AnyPresent;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });\n\n\n// The value is required if all other inputs are not present in the dom\n// the parameter should be formatted as data-parsley-required-with-all=\"#elementValueToCheck,#elementValueToCheck,..\"\nwindow.Parsley\n .addValidator('requiredWithoutAll', {\n requirementType: 'string',\n validateString: function (value, parameters, fieldInstance) {\n // Normalise the parameters\n var allElements = utils.parseArrayStringParameter(parameters);\n\n // Only validate if the char count is 0\n if (value.length == 0) {\n var AllEmpty = true;\n\n allElements.forEach(function (id) {\n var $elem = jQuery(id);\n\n // Check for changes on this other input\n utils.bindChangeToOtherElement('requiredWithAll', id, fieldInstance);\n\n if ($elem.length == 1 && $elem.val() != '') {\n AllEmpty = false;\n }\n });\n\n return AllEmpty;\n }\n\n return true;\n },\n messages: {\n en: 'This field is required.'\n }\n });","import jQuery from 'jquery';\nimport utils from '../utils.js';\n\nvar filesSizes = {\n b: 1,\n kb: 1024,\n mb: 1024 * 1024,\n gb: 1024 * 1024 * 1024,\n};\n\n// Make sure all files within the inputs are equal to or smaller than the defined size.\nwindow.Parsley\n .addValidator('fileSizeMax', {\n requirementType: ['integer', 'string'],\n validateString: function (value, maxSize, sizeMultiplyer, parsleyFieldInstance) {\n sizeMultiplyer = sizeMultiplyer.toLowerCase();\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the max file size\n maxSize = maxSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n console.log(maxSize);\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n console.log(files[i].size);\n if (files[i].size > maxSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) are too big.'\n }\n });\n\n\n// Make sure all files within the inputs are equal to or bigger than the defined size.\nwindow.Parsley\n .addValidator('fileSizeMin', {\n requirementType: ['integer', 'string'],\n validateString: function (value, minSize, sizeMultiplyer, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the min file size\n minSize = minSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (files[i].size < minSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) should are too small.'\n }\n });\n\n\n// Make sure all files within the inputs are between the defined sizes.\nwindow.Parsley\n .addValidator('fileSizeBetween', {\n requirementType: ['integer', 'integer', 'string'],\n validateString: function (value, minSize, maxSize, sizeMultiplyer, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // Multiply the file sizes\n minSize = minSize * filesSizes[sizeMultiplyer.toLowerCase()];\n maxSize = maxSize * filesSizes[sizeMultiplyer.toLowerCase()];\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (files[i].size <= minSize || files[i].size >= maxSize) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'Your file(s) should be between %s and %s %s.'\n }\n });\n\n\n// Make sure all files within the input are an image\nwindow.Parsley\n .addValidator('image', {\n validateString: function (value, param, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (!files[i].type.match('image/*')) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'This is not an image.'\n }\n });\n\n\n// Make sure all files within the input are an image\nwindow.Parsley\n .addValidator('fileMimetype', {\n requirementType: 'string',\n validateString: function (value, mimetypes, parsleyFieldInstance) {\n var allMimes = utils.parseArrayStringParameter(mimetypes);\n\n var files = parsleyFieldInstance.$element[0].files;\n\n // If a file is present in the input\n if (files.length > 0) {\n // Loop over the files\n for (var i = 0; i < files.length; i++) {\n if (allMimes.indexOf(files[i].type) == -1) {\n return false;\n }\n }\n }\n\n return true;\n },\n messages: {\n en: 'This file does not have the correct mimetype \"%s\".'\n }\n });\n\n// Make sure all images withing the input have specific dimensions\nwindow.Parsley\n .addValidator('dimensions', {\n requirementType: {\n '': 'boolean',\n min_width: 'number', // Specify the minimum width the image should have\n max_width: 'number', // Specify the maximum width the image should have\n min_height: 'number', // Specify the minimum height the image should have\n max_height: 'number', // Specify the maximum height the image should have\n width: 'number', // Specify the width the image should have\n height: 'number', // Specify the height the image should have\n ratio: 'string', // Specify the ratio the image should have\n },\n validateString: function (value, param, parsleyFieldInstance) {\n var files = parsleyFieldInstance.$element[0].files;\n\n var options = parsleyFieldInstance.domOptions.dimensionsOptions;\n\n // If a file is present in the input\n if (files.length > 0) {\n var defer = jQuery.Deferred();\n var _URL = window.URL || window.webkitURL;\n\n var image = new Image;\n\n // Validate once t he image is loaded\n image.onload = function () {\n var width = this.width;\n var height = this.height;\n\n // Check min width, if defined\n if (typeof options.min_width != 'undefined') {\n if (width < options.min_width) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check max width, if defined\n if (typeof options.max_width != 'undefined') {\n if (width > options.max_width) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check min height, if defined\n if (typeof options.min_height != 'undefined') {\n if (height < options.min_height) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check max height, if defined\n if (typeof options.max_height != 'undefined') {\n if (height > options.max_height) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check width, if defined\n if (typeof options.width != 'undefined') {\n if (width != options.width) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check height, if defined\n if (typeof options.height != 'undefined') {\n if (height != options.height) {\n defer.reject(image);\n return true;\n }\n }\n\n // Check ratio, if defined\n if (typeof options.ratio != 'undefined') {\n var splitRatio = options.ratio.split(':');\n if (splitRatio[0] / splitRatio[1] != width / height) {\n defer.reject(image);\n return true;\n }\n }\n\n defer.resolve(image);\n };\n\n // On error, reject the promise\n image.onerror = function () {\n console.warn('image load error');\n defer.reject();\n }\n\n image.src = _URL.createObjectURL(files[0]);\n\n return defer.promise().then(function(image){\n // Clean up\n image = null;\n\n return true;\n }, function(image){\n // Clean up\n image = null;\n\n return false;\n });\n }\n\n return true;\n }\n });","import jQuery from 'jquery';\nimport './rules/ins';\nimport './rules/dates';\nimport './rules/comparison';\nimport './rules/requireds.js';\nimport './rules/files.js';\nimport './utils.js';\n\n/**\n * Overwrite core Parsley methods.\n *\n * @type {{_isRequired: Window.ParsleyExtend._isRequired}}\n */\nwindow.ParsleyExtend = {\n // Normally this was intended Internal only.\n // Field is required if have required constraint without `false` value\n _isRequired: function () {\n\n var requiredRules = [\n // This one comes out of the box with parsley\n 'required',\n\n // These ones were added with this library\n 'requiredIf', 'requiredUnless', 'requiredWith', 'requiredWithAll', 'requiredWithout', 'requiredWithoutAll'\n ];\n\n var requiredRulesFound = [];\n\n // Loop over the list to check if they're defined on the field.\n requiredRules.forEach(function (rule) {\n if ('undefined' !== typeof this.constraintsByName[rule]) {\n requiredRulesFound.push(rule);\n }\n }, this);\n\n // If there's not one required rule, return false\n if (requiredRulesFound.length == 0)\n return false;\n\n // If parsley's on required rule was found\n if (requiredRulesFound.indexOf('required') >= 0) {\n // Check if the flag is set to true\n return false !== this.constraintsByName.required.requirements;\n }\n\n return true;\n }\n};\n\nexport default utils;"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/index.html b/index.html index 363414a..328bb98 100644 --- a/index.html +++ b/index.html @@ -790,10 +790,109 @@

Files rules

href="https://laravel.com/docs/5.2/validation#rule-dimensions">dimensions
-
- The image should have a mind width of 100px + The image should have a min width of 100px +
+
+ + +
+
+
+ + dimensions +
+
+ +
+ The image should have a max width of 100px +
+
+
+
+ +
+
+
+ + dimensions +
+
+ +
+ The image should have a min height of 100px +
+
+
+
+
+
+
+ + dimensions +
+
+ +
+ The image should have a max height of 100px +
+
+
+
+ + +
+
+
+ + dimensions +
+
+ +
+ The image should have a width of 100px +
+
+
+
+
+
+
+ + dimensions +
+
+ +
+ The image should have a height of 100px +
+
+
+
+
+
+
+ + dimensions +
+
+ +
+ The image should have ratio of 1:1
diff --git a/package.json b/package.json index aa81276..a958b9b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "parsley-laravel-extras", - "version": "0.4.0", + "version": "0.4.1", "description": "Provides extra validation rules for ParsleyJS that translate well to rules that laravel has out-of-the-box", "main": "dist/laravel-parsley.js", "directories": { diff --git a/src/rules/files.js b/src/rules/files.js index f489d64..c7053bc 100644 --- a/src/rules/files.js +++ b/src/rules/files.js @@ -148,10 +148,6 @@ window.Parsley }); // Make sure all images withing the input have specific dimensions - -//Parsley.addAsyncValidator(); - - window.Parsley .addValidator('dimensions', { requirementType: { @@ -164,109 +160,102 @@ window.Parsley height: 'number', // Specify the height the image should have ratio: 'string', // Specify the ratio the image should have }, - validateString: function (value, param, options, parsleyFieldInstance) { + validateString: function (value, param, parsleyFieldInstance) { var files = parsleyFieldInstance.$element[0].files; + var options = parsleyFieldInstance.domOptions.dimensionsOptions; // If a file is present in the input if (files.length > 0) { var defer = jQuery.Deferred(); + var _URL = window.URL || window.webkitURL; - var file = new FileReader; - - // Set up the image validation when the file is loaded - file.onload = function () { - var image = new Image; + var image = new Image; - // Validate once t he image is loaded - image.onload = function () { - var width = this.width; - var height = this.height; + // Validate once t he image is loaded + image.onload = function () { + var width = this.width; + var height = this.height; - // Check min width, if defined - if (typeof options.min_width != 'undefined') { - console.log(width, options.min_width); - if (width < options.min_width) { - defer.reject(); - return; - } + // Check min width, if defined + if (typeof options.min_width != 'undefined') { + if (width < options.min_width) { + defer.reject(image); + return true; } + } - // Check max width, if defined - if (typeof options.max_width != 'undefined') { - if (width > options.max_width) { - defer.reject(); - return; - } + // Check max width, if defined + if (typeof options.max_width != 'undefined') { + if (width > options.max_width) { + defer.reject(image); + return true; } + } - // Check min height, if defined - if (typeof options.min_height != 'undefined') { - if (height < options.min_height) { - defer.reject(); - return; - } + // Check min height, if defined + if (typeof options.min_height != 'undefined') { + if (height < options.min_height) { + defer.reject(image); + return true; } + } - // Check max height, if defined - if (typeof options.max_height != 'undefined') { - if (height > options.max_height) { - defer.reject(); - return; - } + // Check max height, if defined + if (typeof options.max_height != 'undefined') { + if (height > options.max_height) { + defer.reject(image); + return true; } + } - // Check width, if defined - if (typeof options.width != 'undefined') { - if (width != options.width) { - defer.reject(); - return; - } + // Check width, if defined + if (typeof options.width != 'undefined') { + if (width != options.width) { + defer.reject(image); + return true; } + } - // Check height, if defined - if (typeof options.height != 'undefined') { - if (height != options.height) { - defer.reject(); - return; - } + // Check height, if defined + if (typeof options.height != 'undefined') { + if (height != options.height) { + defer.reject(image); + return true; } + } - // Check ratio, if defined - if (typeof options.ratio != 'undefined') { - var splitRatio = options.ratio.split(':'); - - if (splitRatio[0] / splitRatio[1] != width / height) { - defer.reject(); - return; - } + // Check ratio, if defined + if (typeof options.ratio != 'undefined') { + var splitRatio = options.ratio.split(':'); + if (splitRatio[0] / splitRatio[1] != width / height) { + defer.reject(image); + return true; } - - defer.resolve(); - }; - - // On error, reject the promise - image.onerror = function() { - console.log('image error'); - defer.reject(); } - // Set the image - console.log(file.result); - image.src = file.result; - } + defer.resolve(image); + }; // On error, reject the promise - file.onerror = function() { - console.log('file error'); + image.onerror = function () { + console.warn('image load error'); defer.reject(); } - // Set the file - console.log(files[0]); - file.readAsDataURL(files[0]) + image.src = _URL.createObjectURL(files[0]); + + return defer.promise().then(function(image){ + // Clean up + image = null; + + return true; + }, function(image){ + // Clean up + image = null; - return defer.promise(); + return false; + }); } return true;