public_html/layouts/resources/validator/BaseValidator.min.js.map
{"version":3,"file":"BaseValidator.min.js","sources":["BaseValidator.js"],"sourcesContent":["/*+***********************************************************************************\n * The contents of this file are subject to the vtiger CRM Public License Version 1.0\n * (\"License\"); You may not use this file except in compliance with the License\n * The Original Code is: vtiger CRM Open Source\n * The Initial Developer of the Original Code is vtiger.\n * Portions created by vtiger are Copyright (C) vtiger.\n * All Rights Reserved.\n * Contributor(s): YetiForce S.A.\n *************************************************************************************/\n'use strict';\n\njQuery.Class(\n\t'Vtiger_Base_Validator_Js',\n\t{\n\t\tmoduleName: false,\n\t\t/**\n\t\t *Function which invokes field validation\n\t\t *@param accepts field element as parameter\n\t\t * @return error if validation fails true on success\n\t\t */\n\t\tinvokeValidation: function (field, rules, k, options) {\n\t\t\t//If validation engine already maked the field as error\n\t\t\t// we dont want to proceed\n\t\t\tif (typeof options !== 'undefined') {\n\t\t\t\tif (options.isError === true) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tlet listOfValidators = Vtiger_Base_Validator_Js.getValidator(field);\n\t\t\tfor (let i in listOfValidators) {\n\t\t\t\tlet validatorList = listOfValidators[i],\n\t\t\t\t\tvalidatorName = validatorList.name,\n\t\t\t\t\tvalidatorInstance = new validatorName(),\n\t\t\t\t\tresult;\n\t\t\t\tvalidatorInstance.setElement(field);\n\t\t\t\tif (validatorList.hasOwnProperty('params')) {\n\t\t\t\t\tresult = validatorInstance.validate(validatorList.params);\n\t\t\t\t} else {\n\t\t\t\t\tresult = validatorInstance.validate();\n\t\t\t\t}\n\t\t\t\tif (!result) {\n\t\t\t\t\treturn validatorInstance.getError();\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t/**\n\t\t *Function which gets the complete list of validators based on type and data-validator\n\t\t *@param accepts field element as parameter\n\t\t * @return list of validators for field\n\t\t */\n\t\tgetValidator: function (field) {\n\t\t\tlet listOfValidators = [],\n\t\t\t\tfieldData = field.data(),\n\t\t\t\tfieldInfo = fieldData.fieldinfo;\n\t\t\tif (typeof fieldInfo === 'string') {\n\t\t\t\tfieldInfo = JSON.parse(fieldInfo);\n\t\t\t}\n\t\t\tlet dataValidator = 'validator',\n\t\t\t\tmoduleEle = field.closest('form').find('[name=\"module\"]');\n\t\t\tif (Vtiger_Base_Validator_Js.moduleName === false && moduleEle.length > 0) {\n\t\t\t\tVtiger_Base_Validator_Js.moduleName = moduleEle.val();\n\t\t\t}\n\n\t\t\tlet fieldInstance = Vtiger_Field_Js.getInstance(fieldInfo),\n\t\t\t\tvalidatorsOfType = Vtiger_Base_Validator_Js.getValidatorsFromFieldType(fieldInstance),\n\t\t\t\tkey,\n\t\t\t\tvalue;\n\t\t\tfor (key in validatorsOfType) {\n\t\t\t\t//IE for loop fix\n\t\t\t\tif (!validatorsOfType.hasOwnProperty(key)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tvalue = validatorsOfType[key];\n\t\t\t\tif (value !== '') {\n\t\t\t\t\tlistOfValidators.push({ name: value });\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (fieldData.hasOwnProperty(dataValidator)) {\n\t\t\t\tlet specialValidators = fieldData[dataValidator];\n\t\t\t\tfor (let s in specialValidators) {\n\t\t\t\t\t//IE for loop fix\n\t\t\t\t\tif (!specialValidators.hasOwnProperty(s)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tlet specialValidator = specialValidators[s],\n\t\t\t\t\t\ttempSpecialValidator = jQuery.extend({}, specialValidator),\n\t\t\t\t\t\tvalidatorOfNames = Vtiger_Base_Validator_Js.getValidatorClassName(specialValidator.name);\n\t\t\t\t\tif (validatorOfNames !== '') {\n\t\t\t\t\t\ttempSpecialValidator.name = validatorOfNames;\n\t\t\t\t\t\tif (!jQuery.isEmptyObject(tempSpecialValidator)) {\n\t\t\t\t\t\t\tlistOfValidators.push(tempSpecialValidator);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn listOfValidators;\n\t\t},\n\t\t/**\n\t\t *Function which gets the list of validators based on data type of field\n\t\t *@param accepts fieldInstance as parameter\n\t\t * @return list of validators for particular field type\n\t\t */\n\t\tgetValidatorsFromFieldType: function (fieldInstance) {\n\t\t\tvar fieldType = fieldInstance.getType();\n\t\t\tvar validatorsOfType = [];\n\t\t\tfieldType = fieldType.charAt(0).toUpperCase() + fieldType.slice(1).toLowerCase();\n\t\t\tvalidatorsOfType.push(Vtiger_Base_Validator_Js.getValidatorClassName(fieldType));\n\t\t\treturn validatorsOfType;\n\t\t},\n\t\tgetValidatorClassName: function (validatorName) {\n\t\t\tvar validatorsOfType = '';\n\t\t\tvar className = Vtiger_Base_Validator_Js.getClassName(validatorName);\n\t\t\tvar fallBackClassName = Vtiger_Base_Validator_Js.getFallBackClassName(validatorName);\n\t\t\tif (typeof window[className] !== 'undefined') {\n\t\t\t\tvalidatorsOfType = window[className];\n\t\t\t} else if (typeof window[fallBackClassName] !== 'undefined') {\n\t\t\t\tvalidatorsOfType = window[fallBackClassName];\n\t\t\t}\n\t\t\treturn validatorsOfType;\n\t\t},\n\t\t/**\n\t\t *Function which gets validator className\n\t\t *@param accepts validatorName as parameter\n\t\t * @return module specific validator className\n\t\t */\n\t\tgetClassName: function (validatorName) {\n\t\t\tlet moduleName;\n\t\t\tif (Vtiger_Base_Validator_Js.moduleName != false) {\n\t\t\t\tmoduleName = Vtiger_Base_Validator_Js.moduleName;\n\t\t\t} else {\n\t\t\t\tmoduleName = app.getModuleName();\n\t\t\t}\n\t\t\treturn moduleName + '_' + validatorName + '_Validator_Js';\n\t\t},\n\t\t/**\n\t\t *Function which gets validator className\n\t\t *@param accepts validatorName as parameter\n\t\t * @return generic validator className\n\t\t */\n\t\tgetFallBackClassName: function (validatorName) {\n\t\t\treturn 'Vtiger_' + validatorName + '_Validator_Js';\n\t\t}\n\t},\n\t{\n\t\tfield: '',\n\t\terror: '',\n\t\t/**\n\t\t *Function which validates the field data\n\t\t * @return true\n\t\t */\n\t\tvalidate: function () {\n\t\t\treturn true;\n\t\t},\n\t\t/**\n\t\t *Function which gets error message\n\t\t * @return error message\n\t\t */\n\t\tgetError: function () {\n\t\t\tif (this.error != null) {\n\t\t\t\treturn this.error;\n\t\t\t}\n\t\t\treturn 'Validation Failed';\n\t\t},\n\t\t/**\n\t\t *Function which sets error message\n\t\t * @return Instance\n\t\t */\n\t\tsetError: function (errorInfo) {\n\t\t\tthis.error = errorInfo;\n\t\t\treturn this;\n\t\t},\n\t\t/**\n\t\t *Function which sets field attribute of class\n\t\t * @return Instance\n\t\t */\n\t\tsetElement: function (field) {\n\t\t\tthis.field = field;\n\t\t\treturn this;\n\t\t},\n\t\t/**\n\t\t *Function which gets field attribute of class\n\t\t * @return Instance\n\t\t */\n\t\tgetElement: function () {\n\t\t\treturn this.field;\n\t\t},\n\t\t/**\n\t\t *Function which gets trimed field value\n\t\t * @return fieldValue\n\t\t */\n\t\tgetFieldValue: function () {\n\t\t\tvar field = this.getElement();\n\t\t\treturn jQuery.trim(field.val());\n\t\t}\n\t}\n);\n"],"names":["jQuery","Class","moduleName","invokeValidation","field","rules","k","options","isError","listOfValidators","Vtiger_Base_Validator_Js","getValidator","i","validatorList","validatorName","name","validatorInstance","result","setElement","hasOwnProperty","validate","params","getError","fieldData","data","fieldInfo","fieldinfo","JSON","parse","moduleEle","closest","find","length","val","key","value","fieldInstance","Vtiger_Field_Js","getInstance","validatorsOfType","getValidatorsFromFieldType","push","specialValidators","validator","s","specialValidator","tempSpecialValidator","extend","validatorOfNames","getValidatorClassName","isEmptyObject","fieldType","getType","charAt","toUpperCase","slice","toLowerCase","className","getClassName","fallBackClassName","getFallBackClassName","window","app","getModuleName","error","setError","errorInfo","getElement","getFieldValue","trim"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uFACA,YAAY,CAEZA,MAAM,CAACC,KAAK,CACX,0BAA0B,CAC1B,CACCC,UAAU,CAAA,CAAA,CAAO;AAEnB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