From b92fe3649c1513f986907f31938cad6260ef029e Mon Sep 17 00:00:00 2001 From: Johannes Hoermann <j.hoermann@adito.de> Date: Wed, 9 Jan 2019 10:25:43 +0100 Subject: [PATCH] refactor documentation --- process/PostalAddress_lib/process.js | 38 +++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/process/PostalAddress_lib/process.js b/process/PostalAddress_lib/process.js index eb6dc01da0..b1d113eace 100644 --- a/process/PostalAddress_lib/process.js +++ b/process/PostalAddress_lib/process.js @@ -98,23 +98,45 @@ AddressUtils.getLetterSalutation = function() { */ function AddressValidationUtils(){} +/** + * loads COUNTRYINFO.REQUIRED_FIELDS from db + * + * @param {String} countryCode + * + * @return {String} A string containing all mandatory fieldCodes + * + * @ignore + */ AddressValidationUtils._getRequiredFields = function(countryCode) { if (!countryCode) return ""; - var cond = new SqlCondition(); - cond.andPrepare("COUNTRYINFO.ISO2", countryCode ); - var stmt = cond.buildSelect("select COUNTRYINFO.REQUIRED_FIELDS from COUNTRYINFO"); - var requiredFields = db.cell(stmt); + var requiredFields = db.cell(SqlCondition.begin().andPrepare("COUNTRYINFO.ISO2", countryCode) + .buildSelect("select COUNTRYINFO.REQUIRED_FIELDS from COUNTRYINFO")); return requiredFields; }; +/** + * check if the requested field is a mandatory field + * + * @param {String} countryCode + * @param {String} fieldCode + * + * @return {Boolean} + */ AddressValidationUtils.isMandatoryField = function(countryCode, fieldCode) { var requiredFields = this._getRequiredFields(countryCode); return requiredFields == "" || requiredFields.search(fieldCode) != -1; }; +/** + * load the regexp for zip validation from the database + * + * @param {String} countryCode + * + * @return {String} the regexp + */ AddressValidationUtils._getZipValidationRegEx = function(countryCode) { if (!countryCode) @@ -125,6 +147,14 @@ AddressValidationUtils._getZipValidationRegEx = function(countryCode) return db.cell(stmt); }; +/** + * check if the zip code is valid + * + * @param {String} countryCode + * @param {String} zipCode + * + * return {Boolean} + */ AddressValidationUtils.isValidZip = function(countryCode, zipCode) { if (zipCode == "") -- GitLab