/** * bic validator * * @link http://formvalidation.io/validators/bic/ * @author https://twitter.com/nghuuphuoc * @copyright (c) 2013 - 2015 Nguyen Huu Phuoc * @license http://formvalidation.io/license/ */ (function(root, factory) { "use strict"; // AMD module is defined if (typeof define === "function" && define.amd) { define("validator/bic", ["jquery", "base"], factory); } else { // planted over the root! factory(root.jQuery, root.FormValidation); } }(this, function ($, FormValidation) { FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, { 'en_US': { bic: { 'default': 'Please enter a valid BIC number' } } }); FormValidation.Validator.bic = { /** * Validate an Business Identifier Code (BIC), also known as ISO 9362, SWIFT-BIC, SWIFT ID or SWIFT code * * For more information see http://en.wikipedia.org/wiki/ISO_9362 * * @todo The 5 and 6 characters are an ISO 3166-1 country code, this could also be validated * @param {FormValidation.Base} validator The validator plugin instance * @param {jQuery} $field Field element * @param {Object} options Can consist of the following keys: * - message: The invalid message * @returns {Object} */ validate: function(validator, $field, options) { var value = validator.getFieldValue($field, 'bic'); if (value === '') { return true; } return /^[a-zA-Z]{6}[a-zA-Z0-9]{2}([a-zA-Z0-9]{3})?$/.test(value); } }; return FormValidation.Validator.bic; }));