' )
+ .html(
+ '' +
+ '= ' + val +
+ ''
+ )
+ )
+ )
+ ;
+ },
+
+
+ 'private _appendHeader': function( $ret )
+ {
+ // this used to reference "premium", but has been generalized
+ $ret.append( $( '' ).html(
+ 'Below you will find values that were hand-selected as ' +
+ 'useful data. Only non-zero calculations are ' +
+ 'displayed, so if a calculation results in 0, ' +
+ 'you must click on "More Detail" to see it. For more ' +
+ 'complex calculations, only applicable portions may be ' +
+ 'displayed.'
+ ) );
+ },
+
+
+ 'private _processSet': function( data, delims, index )
+ {
+ if ( data.length === 0 )
+ {
+ return '';
+ }
+
+ var $ret = this._jquery( '' ),
+ $add = $ret,
+ $group;
+
+ if ( delims.length > 1 )
+ {
+ $ret.append( $group = $( '' ) );
+ $add = $group;
+
+ $group.append( '(' );
+ }
+
+ var n = 0;
+ for ( var i in data )
+ {
+ if ( data[ i ] === undefined )
+ {
+ continue;
+ }
+
+ $add.append(
+ this._processCalc(
+ data[ i ],
+ delims,
+ ( n++ === 0 ) /* do not apply delim to first */,
+ index
+ )
+ );
+ }
+
+ if ( delims.length > 1 )
+ {
+ $group
+ .append( ')' )
+ .append( '
' );
+ }
+
+ return $ret;
+ },
+
+
+ 'private _processCalc': function( data, delims, first, index )
+ {
+ first = !!first;
+
+ var type = data[ 0 ],
+ desc = data[ 1 ],
+ sub = data[ 2 ],
+ val = ( data[ 3 ] || [] )[ index ],
+
+ $ = this._jquery,
+ $ret = $( '' );
+
+ if ( ( val === undefined ) || ( val === null ) )
+ {
+ val = data[ 3 ];
+ }
+
+ // render only the first argument (which is presumably the meat)
+ if ( type === 'apply' )
+ {
+ sub = [ sub[ 0 ] ];
+ }
+
+ // just in case we're provided with an array
+ if ( !val || ( typeof val === 'object' ) && ( val.length === 0 ) )
+ {
+ val = ( desc.value || '0' );
+ }
+
+ // if we're a sub-equation (denoted by delimiters) with no value, then
+ // neglect to display anything
+ if ( delims.length && !data[ 3 ] )
+ {
+ //return null;
+ }
+
+ // should we ignore this calculation?
+ if ( this._shouldIgnoreOutput( type, desc, sub, val ) )
+ {
+ return '';
+ }
+
+ // should we ignore the parent output (only output children)?
+ var ignore_poutput = this._shouldIgnorePOutput( type, desc, sub, val );
+
+ $ret
+ .append( $( '' )
+ .html(
+ ( ( delims.length && !first && !ignore_poutput )
+ ? ( ''
+ + delims[ delims.length - 1 ]
+ + ''
+ )
+ : ''
+ ) +
+ ( ( !ignore_poutput )
+ ? this._styleType( type, desc, val, sub )
+ : ''
+ )
+ )
+ )
+ .append(
+ this._processSet( sub, this._addDelim( delims, type ), index )
+ );
+
+ return $ret;
+ },
+
+
+ 'private _shouldIgnoreOutput': function( type, desc, sub, val )
+ {
+ // ignore all cases except for the one that yielded a value
+ if ( ( ( type === 'case' || type === 'otherwise' ) ) && !( +val > 0 ) )
+ {
+ return true;
+ }
+ else if ( type === 'when' )
+ {
+ return true;
+ }
+
+ return false;
+ },
+
+
+ 'private _shouldIgnorePOutput': function( type, desc, sub, val )
+ {
+ // ignore all cases except for the one that yielded a value
+ switch ( type )
+ {
+ case 'cases':
+ return true;
+ }
+
+ return false;
+ },
+
+
+ 'private _styleType': function( type, desc, val, sub )
+ {
+ switch ( type )
+ {
+ case 'arg':
+ case 'product':
+ case 'quotient':
+ case 'sum':
+ case 'cases':
+ case 'case':
+ case 'when':
+ case 'otherwise':
+ return '';
+
+ case 'apply':
+ if ( sub.length )
+ {
+ return '' +
+ this._applyName( desc.name ) +
+ '';
+ }
+
+ // intentional fallthrough (how useful!)
+
+ case 'value-of':
+ default:
+ var name = desc.label || desc.name || desc.desc || '';
+
+ if ( name )
+ {
+ return '[' +
+ name + ' = ' + val +
+ ']';
+ }
+ else
+ {
+ return val;
+ }
+ }
+ },
+
+
+ /**
+ * More understandable text for certain function names
+ *
+ * TODO: Move somewhere else
+ */
+ 'private _applyName': function( name )
+ {
+ switch ( name )
+ {
+ case 'max': return "The larger of";
+ case 'round_real': return 'Round to the nearest integer';
+ }
+
+ return name;
+ },
+
+
+ 'private _addDelim': function( delims, type )
+ {
+ // create a copy (then we don't have to worry about popping elements
+ // off)
+ delims = ( delims ) ? delims.slice() : [];
+
+ var delim = ( function()
+ {
+ switch ( type )
+ {
+ case 'sum': return '+';
+ case 'quotient': return '/';
+ case 'product': return '*';
+
+ default: return '';
+ }
+ } )();
+
+ if ( delim )
+ {
+ delims.push( delim );
+ }
+
+ return delims;
+ }
+} );
+
diff --git a/src/util/ArrayDiff.js b/src/util/ArrayDiff.js
new file mode 100644
index 0000000..83f77ba
--- /dev/null
+++ b/src/util/ArrayDiff.js
@@ -0,0 +1,41 @@
+/**
+ * Interface for performing basic array diffs
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+var Interface = require( 'easejs' ).Interface;
+
+
+module.exports = Interface( 'ArrayDiff',
+{
+ /**
+ * Return non-matching indexes and their values
+ *
+ * The returned array will set the value of the associated changed index to
+ * an array containing both values of a and b respectively; unchanged
+ * indexes will be undefined.
+ *
+ * @param {Array} a first array to compare
+ * @param {Array} b second array to compare
+ *
+ * @return {Array.Array.<*>} an array of non-matching values
+ */
+ 'public diff': [ 'a', 'b' ]
+} );
+
diff --git a/src/util/ShallowArrayDiff.js b/src/util/ShallowArrayDiff.js
new file mode 100644
index 0000000..d5342c3
--- /dev/null
+++ b/src/util/ShallowArrayDiff.js
@@ -0,0 +1,60 @@
+/**
+ * Performs a strict shallow diff on the values of two arrays
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+var Class = require( 'easejs' ).Class,
+ ArrayDiff = require( './ArrayDiff' );
+
+
+module.exports = Class( 'ShallowArrayDiff' )
+ .implement( ArrayDiff )
+ .extend(
+{
+ /**
+ * Return the strictly non-matching indexes and their values
+ *
+ * The returned array will set the value of the associated changed index to
+ * an array containing both values of a and b respectively; unchanged
+ * indexes will be undefined.
+ *
+ * @param {Array} a first array to compare
+ * @param {Array} b second array to compare
+ *
+ * @return {Array.Array.<*>} an array of non-matching values
+ */
+ 'public diff': function( a, b )
+ {
+ var longer = ( a.length > b.length ) ? a : b,
+ i = longer.length,
+ changed = [];
+
+ // for each index, return both values if they do not strictly match
+ while ( i-- )
+ {
+ if ( a[ i ] !== b[ i ] )
+ {
+ changed[ i ] = [ a[ i ], b[ i ] ];
+ }
+ }
+
+ return changed;
+ }
+} );
+
diff --git a/src/validate/formatter/AddressFormatter.js b/src/validate/formatter/AddressFormatter.js
new file mode 100644
index 0000000..8efeb5b
--- /dev/null
+++ b/src/validate/formatter/AddressFormatter.js
@@ -0,0 +1,29 @@
+/**
+ * Validates address format
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+
+module.exports = require( './PatternFormatter' )(
+ [
+ /^[a-zA-Z0-9-.]+ +[a-zA-Z0-9 &\/'.,-]+$/,
+ '$&'
+ ]
+);
+
diff --git a/src/validate/formatter/CcExpDateFormatter.js b/src/validate/formatter/CcExpDateFormatter.js
new file mode 100644
index 0000000..528d20c
--- /dev/null
+++ b/src/validate/formatter/CcExpDateFormatter.js
@@ -0,0 +1,40 @@
+/**
+ * Contains validator for credit card expiration dates
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+
+module.exports = require( './PatternFormatter' )(
+ [
+ /^(0?[1-9]|1[012])[/ -]*(20\d{2})$/,
+
+ function( _, month, year )
+ {
+ var curyear = ( new Date() ).getFullYear();
+
+ if ( ( year < curyear ) || ( year > ( curyear + 10 ) ) )
+ {
+ throw Error( 'Year outside of allowed range' );
+ }
+
+ return month + '/' + year;
+ }
+ ]
+);
+
diff --git a/src/validate/formatter/CcNumberFormatter.js b/src/validate/formatter/CcNumberFormatter.js
new file mode 100644
index 0000000..3a94098
--- /dev/null
+++ b/src/validate/formatter/CcNumberFormatter.js
@@ -0,0 +1,49 @@
+/**
+ * Contains validator for credit card numbers
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+
+/**
+ * Simply validates cc number length
+ *
+ * This does not check the validity of the data entered (that is --- we do not
+ * perform a checksum).
+ *
+ * We do not format the output in any particular manner, as different carriers
+ * may provider different styles.
+ */
+module.exports = require( './PatternFormatter' )(
+ [
+ /^[0-9 -]+$/, function( match )
+ {
+ // remove set delimiters
+ var result = match.replace( /[ -]/g, '' );
+
+ // easier to simply check here rather than convoluting the regex
+ if ( ( result.length < 15 ) || ( result.length > 16 ) )
+ {
+ throw Error( 'Invalid length' );
+ }
+
+ return result;
+ }
+ ]
+);
+
diff --git a/src/validate/formatter/CityFormatter.js b/src/validate/formatter/CityFormatter.js
new file mode 100644
index 0000000..051b2f1
--- /dev/null
+++ b/src/validate/formatter/CityFormatter.js
@@ -0,0 +1,29 @@
+/**
+ * Validates city format
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+
+module.exports = require( './PatternFormatter' )(
+ [
+ /^[a-zA-Z][a-zA-Z '.-]+$/,
+ '$&'
+ ]
+);
+
diff --git a/src/validate/formatter/Currency.js b/src/validate/formatter/CurrencyFormatter.js
similarity index 97%
rename from src/validate/formatter/Currency.js
rename to src/validate/formatter/CurrencyFormatter.js
index 757f7a9..238fc73 100644
--- a/src/validate/formatter/Currency.js
+++ b/src/validate/formatter/CurrencyFormatter.js
@@ -27,7 +27,7 @@
* Currency().parse( '$123' ); // => 123.00
* Currency().retrieve( '123.4' ); // => $123.40
*
- * @class Currency
+ * @class CurrencyFormatter
* @mixes module:validate/formatter.Number
* @mixes module:validate/formatter.StringFormat
*/
diff --git a/src/validate/formatter/Cvv2Formatter.js b/src/validate/formatter/Cvv2Formatter.js
new file mode 100644
index 0000000..9111f7b
--- /dev/null
+++ b/src/validate/formatter/Cvv2Formatter.js
@@ -0,0 +1,27 @@
+/**
+ * Formats and validates CVV2 Numbers
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+
+module.exports = require( './PatternFormatter' )(
+ [ /^[0-9]{3,4}$/, '$&' ],
+ [ /.?/, '$&' ]
+);
+
diff --git a/src/validate/formatter/DateValidator.js b/src/validate/formatter/DateValidator.js
new file mode 100644
index 0000000..0f5cdbd
--- /dev/null
+++ b/src/validate/formatter/DateValidator.js
@@ -0,0 +1,232 @@
+/**
+ * Contains date validation/formatting methods
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+var Class = require( 'easejs' ).Class;
+
+
+/**
+ * Data validation and formatting
+ */
+module.exports = Class( 'DateValidator',
+{
+ /**
+ * Retrieve the numeric month id, 1-indexed, from the given string
+ *
+ * @param {string} name month name
+ *
+ * @return {number} month id, 1-indexed
+ */
+ 'private _getMonthId': function( name )
+ {
+ // get numerical equivalent of month (getMonth() is 0-indexed)
+ var month = ( ( new Date( '1 ' + name + ' 2000' ) )
+ .getMonth() + 1
+ );
+
+ // if they entered an invalid month string, then we should invalidate the
+ // match by throwing an exception
+ if ( isNaN( month ) )
+ {
+ throw TypeError( 'Invalid month' );
+ }
+
+ return month;
+ },
+
+
+ 'private _validateMonthDay': function( month, day, leapyear )
+ {
+ if ( month < 1 || month > 12 )
+ {
+ throw TypeError( 'Invalid month' );
+ }
+
+ var lengths = [ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];
+
+ lengths[2] = leapyear ? 29 : 28;
+
+ if ( day < 1 || day > lengths[month] )
+ {
+ throw TypeError( 'Invalid day' );
+ }
+ },
+
+
+ /**
+ * Build a date regular expression
+ *
+ * @return {RegExp} date regular expression
+ */
+ 'public getDateRegExp': function()
+ {
+ // made an attempt to format this in a way that is remotely
+ // legible, but JS regexes don't support special formatting
+ // options like Perl (and consequently PHP's preg_*)
+ return new RegExp(
+ '^' +
+ // 1-2 digit month or day, or 4-digit year, or month name
+ '(?:' +
+ '([012]?[0-9]|3[01]|(?:19|20)\\d{2})' +
+ '|([a-zA-Z]{3,})' +
+ ')' +
+ '[/ -]*' +
+
+ // 1-2 digit month or day, or month name (notice the
+ // non-greedy match for the digits, which will
+ // ensure that the year takes precidence in bizzare
+ // matches like "Oct589")
+ '(?:' +
+ '([012]?[0-9]|3[01]?)' +
+ '|([a-zA-Z]{3,})' +
+ ')' +
+ '[/ -]*' +
+
+ // 1-2 digit day, or 4-digit year
+ '(0?[1-9]|1[012]|(?:19|20)?\\d{2})' +
+ '$'
+ );
+ },
+
+
+ /**
+ * Normalizes full date using matches from the date regex
+ *
+ * @return {string} normalized date string
+ */
+ 'public normalizeFullDate': function( match, p1, p1_str, p2, p2_str, p3 )
+ {
+ var date_parts = this._normalizeDate.apply( this, arguments );
+
+ return date_parts.join( '-' );
+ },
+
+
+ /**
+ * Normalizes short date using matches from the date regex
+ *
+ * @return {string} normalized date string
+ */
+ 'public normalizeShortDate': function( match, p1, p1_str, p2, p2_str, p3 )
+ {
+ var shortReg = new RegExp( /^(0?[1-9]|1[012])[ \/]*((19|20)\d{2})$/ ),
+ parts = match.match( shortReg );
+
+ if ( parts )
+ {
+ // check short date mm/yyyy first
+ var parts = shortReg.exec( match ),
+ month = parts[1],
+ year = parts[2];
+
+ month = ( month.length < 2 )
+ ? '0' + ''+month
+ : month;
+
+ return month + '/' + year;
+ }
+ else
+ {
+ // the input is more complicated,
+ // attempt to normalize the full date
+ var date_parts = this._normalizeDate.apply( this, arguments );
+ return date_parts[ 1 ] + '/' + date_parts[ 0 ];
+ }
+ },
+
+
+ /**
+ * Normalizes date using matches from the date regex
+ *
+ * The match arguments and groups may be confusing; this is because the
+ * data they can contain varies drastically. The nomenclature for these
+ * parameters comes from MDN.
+ *
+ * For information on what each specific argument can contain, see their
+ * respective match groups in the data regular expression.
+ *
+ * @param {string} match full match (entire date string)
+ * @param {string} p1 first set match, numeric
+ * @param {string} p1_str first set alternative match, string
+ * @param {string} p2 second set match (3rd group); numeric
+ * @param {string} p2_str second set alternative match; string
+ * @param {string} p3 third set match (5th group); numeric
+ *
+ * @return {Array=} containing date parts year, month, day
+ */
+ 'private _normalizeDate': function( match, p1, p1_str, p2, p2_str, p3 )
+ {
+ var month, day, year;
+
+ // we cannot reliably determine the date they intended
+ // to relay with less than 6 characters (see tests)
+ if ( match.length < 6 )
+ {
+ throw Error( 'Date is too ambigious' );
+ }
+
+ // is the year first?
+ if ( ( p1 || '' ).length === 4 )
+ {
+ year = +p1;
+ month = +( p2 || this._getMonthId( p2_str ) );
+ day = +p3;
+ }
+ // e.g. "5 Oct 2012"
+ else if ( p2_str )
+ {
+ month = +this._getMonthId( p2_str );
+ day = +p1;
+ year = +p3;
+ }
+ // year is last
+ else
+ {
+ month = +( p1 || this._getMonthId( p1_str ) );
+ day = +p2;
+ year = +p3;
+ }
+
+ // format year as a 4-digit year (it is no longer a string, use
+ // compare numerically)
+ if ( year < 100 )
+ {
+ // yes, convoluted math; makes intent clear
+ var cutoff = ( new Date() ).getFullYear() - 2000 + 10;
+
+ padding = ( year < 10 ) ? '0' : '';
+
+ year = ( year < cutoff )
+ ? '20' + padding + year
+ : '19' + padding + year;
+ }
+
+ this._validateMonthDay(
+ month, day, ( ( new Date(year, 1, 29) ).getMonth() == 1 )
+ );
+
+ // return date parts
+ return [
+ year,
+ ( ( month < 10 ) ? ( '0' + ''+month ) : month ),
+ ( ( day < 10 ) ? ( '0' + ''+day ) : day )
+ ];
+ }
+} );
diff --git a/src/validate/formatter/DbaFormatter.js b/src/validate/formatter/DbaFormatter.js
new file mode 100644
index 0000000..c11ca09
--- /dev/null
+++ b/src/validate/formatter/DbaFormatter.js
@@ -0,0 +1,31 @@
+/**
+ * Contains validator for DBA names
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+
+/**
+ * DBA names can contain more characters than names of people
+ */
+module.exports = require( './PatternFormatter' )(
+ [
+ /^[a-zA-Z0-9 '\.,\-\&\(\):\/]+$/, '$&'
+ ]
+);
+
diff --git a/src/validate/formatter/DollarFormatter.js b/src/validate/formatter/DollarFormatter.js
new file mode 100644
index 0000000..429944f
--- /dev/null
+++ b/src/validate/formatter/DollarFormatter.js
@@ -0,0 +1,39 @@
+/**
+ * @license
+ * Dollar formatter
+ *
+ * Copyright (C) 2016 LoVullo Associates, Inc.
+ *
+ * This file is part of liza.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * Currency of the form `$%d`
+ *
+ * @see Currency
+ *
+ * @example
+ * Currency().parse( '$123' ); // => 123.00
+ * Currency().retrieve( '123.4' ); // => $123.40
+ *
+ * @class DollarFormatter
+ * @mixes module:validate/formatter.Number
+ * @mixes module:validate/formatter.StringFormat
+ */
+module.exports = require( './EchoFormatter' )
+ .use( require( './Number' )( 0 ) )
+ .use( require( './StringFormat' )( '$%s' ) );
+
diff --git a/src/validate/formatter/EmailFormatter.js b/src/validate/formatter/EmailFormatter.js
new file mode 100644
index 0000000..14e06d0
--- /dev/null
+++ b/src/validate/formatter/EmailFormatter.js
@@ -0,0 +1,76 @@
+/**
+ * Contains e-mail address validator
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+// characters allowed in local-part, omitting dot (some of these are only
+// allowed within quotes, but we're not going to bother convuluting the regex
+// with that)
+var local_chars = '[a-zA-Z0-9!#$%&\'*+/=?^_1{|}~()\\\\" (),:;<>@\\[\\]-]';
+
+
+/**
+ * Validates e-mail addresses
+ *
+ * See RFCs 5321, 5322 and 6531. The "Email address" Wikipedia page provides a
+ * nice summary, which was used to create this regex.
+ *
+ * RFC 6531 supports all characters above U+007F, but this regex will *not*
+ * permit them, since we make no attempt to support multibyte strings within
+ * PHP (and PHP does not support them by default).
+ */
+module.exports = require( './PatternFormatter' )(
+ [
+ new RegExp(
+ // begin local-part
+ '^' +
+ // dots cannot be the first character (negative look-ahead does
+ // not consume any chars)
+ '(?!\\.)' +
+
+ // dots may appear, so long as they are not first or last in
+ // local-part, and mustn't appear more than once consecutively
+ // (this is not terribly efficient, but the local_chars portion
+ // will match 99% of the time, avoiding most penalties...and
+ // we'd be micro-optimizing, consider the use case of this
+ // validator)
+ '(?:' +
+ local_chars +
+ '|\\.(?!\\.)' +
+ ')+' +
+
+ // Dots may not appear at the end of local-part. The problem
+ // here is that JS does not support negative look-behinds (total
+ // bullshit), so we must use this ugly solution instead.
+ local_chars +
+
+ // begin domain portion
+ '@' +
+ // Must be a valid hostname and may contain comments in
+ // parenthesis. IPs are technically allowed in brackets, but
+ // we're not going to support that crap.
+ '[a-zA-Z0-9-.()]+' +
+ '$'
+ ),
+
+ // no special formatting will be done
+ '$&'
+ ]
+);
+
diff --git a/src/validate/formatter/FloatFormatter.js b/src/validate/formatter/FloatFormatter.js
new file mode 100644
index 0000000..7d82003
--- /dev/null
+++ b/src/validate/formatter/FloatFormatter.js
@@ -0,0 +1,44 @@
+/**
+ * Validates float format
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+
+module.exports = require( './PatternFormatter' )(
+ [
+ /^([0-9, ]*)(?:\.([0-9]{1,2})?)?$/,
+ function( _, number, decimals )
+ {
+ decimals = decimals || '00';
+
+ // return as %.2f, stripping commas, spaces and leading
+ // zeros
+ return (
+ number.replace( /[, ]/g, '' )
+ .replace( /^0*?(0)?$|^0*/, '$1' ) +
+ '.' +
+ ( ( decimals.length === 2 )
+ ? decimals
+ : ( decimals + '0' )
+ )
+ );
+ }
+ ]
+);
+
diff --git a/src/validate/formatter/FullDateFormatter.js b/src/validate/formatter/FullDateFormatter.js
new file mode 100644
index 0000000..0afa3e8
--- /dev/null
+++ b/src/validate/formatter/FullDateFormatter.js
@@ -0,0 +1,45 @@
+/**
+ * Contains FullDateValidator VFormat instance
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+var date_parts = require( './DateValidator' )();
+
+
+/**
+ * Normalizes the date to a common YYYY-MM-DD format
+ *
+ * Will format as MM/DD/YYYY for diplay in rater
+ */
+module.exports = require( './PatternFormatter' )(
+ [
+ date_parts.getDateRegExp(),
+
+ function( match, p1, p1_str, p2, p2_str, p3 )
+ {
+ return date_parts.normalizeFullDate(
+ match, p1, p1_str, p2, p2_str, p3
+ );
+ }
+ ],
+
+ // returns results formatted in MM/DD/YYYY format
+ [ /^(\d{4})-0?(\d{1,2})-0?(\d{1,2})$/, "$2/$3/$1" ]
+);
+
diff --git a/src/validate/formatter/InitialFormatter.js b/src/validate/formatter/InitialFormatter.js
new file mode 100644
index 0000000..a7d5a41
--- /dev/null
+++ b/src/validate/formatter/InitialFormatter.js
@@ -0,0 +1,28 @@
+/**
+ * Validates an initial
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+
+module.exports = require( './PatternFormatter' )(
+ [
+ /^[a-zA-Z]$/, '$&'
+ ]
+);
+
diff --git a/src/validate/formatter/NameFormatter.js b/src/validate/formatter/NameFormatter.js
new file mode 100644
index 0000000..ed87dec
--- /dev/null
+++ b/src/validate/formatter/NameFormatter.js
@@ -0,0 +1,29 @@
+/**
+ * Validates names (latin characters)
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+
+module.exports = require( './PatternFormatter' )(
+ [
+ /^[a-zA-Z][a-zA-Z '.-]*$/,
+ '$&'
+ ]
+);
+
diff --git a/src/validate/formatter/NonPoBoxAddressFormatter.js b/src/validate/formatter/NonPoBoxAddressFormatter.js
new file mode 100644
index 0000000..0709ef7
--- /dev/null
+++ b/src/validate/formatter/NonPoBoxAddressFormatter.js
@@ -0,0 +1,57 @@
+/**
+ * Validates non po box address format
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+var pobox_regex = new RegExp(
+ '\\b' +
+ '(' +
+ '(' +
+ 'p(ost)?' +
+ '\\W?\\s*' +
+ '(\\d+|o(ff(ice)?)?)' +
+ '\\W?\\s*' +
+ '(b(in|ox)?)?' +
+ '\\W?\\s*' +
+ ')' +
+ '|' +
+ 'b(in|ox)?' +
+ '\\W?\\s*' +
+ ')' +
+ '\\s*\\b',
+ 'i'
+);
+
+
+module.exports = require( './PatternFormatter' )(
+ [
+ /^[a-zA-Z0-9-.]+ +[a-zA-Z0-9 &\/'.,-]+$/,
+
+ function( match )
+ {
+ if ( pobox_regex.test( match ) )
+ {
+ throw Error( "PO Box" );
+ }
+
+ return match;
+ }
+ ]
+);
+
diff --git a/src/validate/formatter/PersonalIdFormatter.js b/src/validate/formatter/PersonalIdFormatter.js
new file mode 100644
index 0000000..1528722
--- /dev/null
+++ b/src/validate/formatter/PersonalIdFormatter.js
@@ -0,0 +1,43 @@
+/**
+ * Contains PersonalIdValidator
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+
+/**
+ * Validates SSN and FEIN formats
+ */
+module.exports = require( './PatternFormatter' )(
+ [
+ /^[0-9- ]+$/, function( match )
+ {
+ var result = match.replace( /[ -]/g, '' );
+
+ // easier to perform the length check in here than the regex, once
+ // we strip everything out
+ if ( result.length !== 9 )
+ {
+ throw Error( 'Invalid length' );
+ }
+
+ return result;
+ }
+ ]
+);
+
diff --git a/src/validate/formatter/PhoneFormatter.js b/src/validate/formatter/PhoneFormatter.js
new file mode 100644
index 0000000..8208f09
--- /dev/null
+++ b/src/validate/formatter/PhoneFormatter.js
@@ -0,0 +1,52 @@
+/**
+ * Contains PhoneValidator
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+
+/**
+ * Validates format of phone numbers
+ */
+module.exports = require( './PatternFormatter' )(
+ [
+ new RegExp(
+ '^' +
+ // ignore leading 1 (US/Canada country code)
+ '(?:1[ .-]*)?' +
+
+ // area code with optional parenthesis
+ '\\(?([0-9]{3})\\)?' +
+ '[ .-]*' +
+
+ // remainder of phone number, with or without delimiters
+ '([0-9]{3})' +
+ '[ .-]*' +
+ '([0-9]{4})' +
+ '$'
+ ),
+
+ '$1$2$3'
+ ],
+
+ [ /^([0-9]{3})?([0-9]{3})([0-9]{4})$/, function( _, p1, p2, p3 )
+ {
+ return ( ( ( p1 ) ? ( p1 + '-' ) : '' ) + p2 + '-' + p3 );
+ } ]
+);
+
diff --git a/src/validate/formatter/QuoteIdFormatter.js b/src/validate/formatter/QuoteIdFormatter.js
new file mode 100644
index 0000000..93d2236
--- /dev/null
+++ b/src/validate/formatter/QuoteIdFormatter.js
@@ -0,0 +1,33 @@
+/**
+ * Contains quote id validator
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+
+/**
+ * Validates quote ids
+ *
+ * A quote id must be numeric and may optionally begin with WEB.
+ */
+module.exports = require( './PatternFormatter' )(
+ [
+ /^(?:WEB)? *([1-9][0-9]{5,})$/, '$1'
+ ]
+);
+
diff --git a/src/validate/formatter/README b/src/validate/formatter/README
new file mode 100644
index 0000000..ac044bd
--- /dev/null
+++ b/src/validate/formatter/README
@@ -0,0 +1,7 @@
+Validator/Formatters
+====================
+
+A number of these formatters are written in an old style using
+PatternFormatter. Where it makes sense, they should be converted into
+traits or concrete mixins.
+
diff --git a/src/validate/formatter/ShortDateFormatter.js b/src/validate/formatter/ShortDateFormatter.js
new file mode 100644
index 0000000..7082d90
--- /dev/null
+++ b/src/validate/formatter/ShortDateFormatter.js
@@ -0,0 +1,43 @@
+/**
+ * Contains ShortDateValidator VFormat instance
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+var date_parts = require( './DateValidator' )();
+
+
+/**
+ * Validates and formats dates in a MM/YYYY format
+ */
+module.exports = require( './PatternFormatter' )(
+ [
+ date_parts.getDateRegExp(),
+
+ function( match, p1, p1_str, p2, p2_str, p3 )
+ {
+ return date_parts.normalizeShortDate(
+ match, p1, p1_str, p2, p2_str, p3
+ );
+ }
+ ],
+
+ // returns results formatted in MM/YYYY format
+ [ /^(\d{4})-0?(\d{1,2})-0?(\d{1,2})$/, "$2/$1" ]
+);
+
diff --git a/src/validate/formatter/UrlFormatter.js b/src/validate/formatter/UrlFormatter.js
new file mode 100644
index 0000000..bb2f63d
--- /dev/null
+++ b/src/validate/formatter/UrlFormatter.js
@@ -0,0 +1,45 @@
+/**
+ * Validates URLs according to RFC 1738
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+
+module.exports = require( './PatternFormatter' )(
+ [
+ new RegExp(
+ '^' +
+ // optional protocol (we only permit http and ftp...no no
+ // particular reason, unless you can think of a reason to accept
+ // others)
+ '(?:(?:ht|f)tps?://)?' +
+
+ // hostname
+ '[\\w\\d-]+[\\w\\d.-]*' +
+
+ // optionally a filename, parameters, etc after the hostname, so
+ // long as it is delimited by a forward slash
+ '(?:/[\\w\\d$_.+!*\'(),%?:@=&;-]*)?' +
+ '$'
+ ),
+
+ // no formatting
+ '$&'
+ ]
+);
+
diff --git a/src/validate/formatter/VoidFormatter.js b/src/validate/formatter/VoidFormatter.js
new file mode 100644
index 0000000..63bcd6e
--- /dev/null
+++ b/src/validate/formatter/VoidFormatter.js
@@ -0,0 +1,27 @@
+/**
+ * Does nothing.
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+
+module.exports = require( './PatternFormatter' )(
+ [ /.?/, '$&' ],
+ [ /.?/, '$&' ]
+);
+
diff --git a/src/validate/formatter/YearFormatter.js b/src/validate/formatter/YearFormatter.js
new file mode 100644
index 0000000..ed65aec
--- /dev/null
+++ b/src/validate/formatter/YearFormatter.js
@@ -0,0 +1,29 @@
+/**
+ * Validates year format
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+
+module.exports = require( './PatternFormatter' )(
+ [
+ // brace yourselves.
+ /^[12][0-9]{3}$/, '$&'
+ ]
+);
+
diff --git a/src/validate/formatter/ZipFormatter.js b/src/validate/formatter/ZipFormatter.js
new file mode 100644
index 0000000..2855010
--- /dev/null
+++ b/src/validate/formatter/ZipFormatter.js
@@ -0,0 +1,28 @@
+/**
+ * Validates format of U.S. zip codes
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+
+module.exports = require( './PatternFormatter' )(
+ [
+ /^([0-9]{5})[ -]*(?:[0-9]{4})?$/, '$1'
+ ]
+);
+
diff --git a/src/validate/standardBucketValidator.js b/src/validate/standardBucketValidator.js
new file mode 100644
index 0000000..817ee8f
--- /dev/null
+++ b/src/validate/standardBucketValidator.js
@@ -0,0 +1,106 @@
+/**
+ * Standard formatters
+ *
+ * Copyright (C) 2017 LoVullo Associates, Inc.
+ *
+ * This file is part of the Liza Data Collection Framework.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * @todo This is a relic; make modern.
+ */
+
+var formatter = require( './formatter' ),
+ Base = formatter.EchoFormatter;
+
+
+/**
+ * Partially applied function to return a bucket validator with the standard set
+ * of validations
+ *
+ * Accepts only a map of each field to its type.
+ */
+module.exports = function( type_map )
+{
+ return require( 'liza/validate/BucketDataValidator' )(
+ type_map,
+
+ // standard validators
+ {
+ address: formatter.AddressFormatter,
+ ccExpDate: formatter.CcExpDateFormatter,
+ ccNumber: formatter.CcNumberFormatter,
+ city: formatter.CityFormatter,
+ currency: formatter.CurrencyFormatter(),
+ 'float': formatter.FloatFormatter,
+ date: formatter.FullDateFormatter,
+ dollars: formatter.DollarFormatter(),
+ manualDate: formatter.FullDateFormatter,
+ csr: formatter.DbaFormatter,
+ dba: formatter.DbaFormatter,
+ email: formatter.EmailFormatter,
+ name: formatter.NameFormatter,
+ nonPoBoxAddress: formatter.NonPoBoxAddressFormatter,
+ initial: formatter.InitialFormatter,
+ number: Base.use( formatter.Number )(),
+ personalId: formatter.PersonalIdFormatter,
+ phone: formatter.PhoneFormatter,
+ quoteId: formatter.QuoteIdFormatter,
+ shortDate: formatter.ShortDateFormatter,
+ url: formatter.UrlFormatter,
+ year: formatter.YearFormatter,
+ zip: formatter.ZipFormatter,
+ cvv2: formatter.Cvv2Formatter,
+ unorderedList: Base.use( formatter.UnorderedList )(),
+
+ // generic type (see lv:external in program UI compiler output);
+ // ignore entirely
+ 'undefined': null,
+
+ multitext: Base.use( formatter.MultiDimension( '; ' ) )(),
+ multilimit: formatter.insurance.StandardLimitFormatter
+ .use( formatter.MultiDimension( '; ' ) )(),
+
+ // no validators for these (yet)
+ select: formatter.VoidFormatter,
+ noyes: formatter.VoidFormatter,
+ radio: formatter.VoidFormatter,
+ legacyradio: formatter.VoidFormatter,
+ text: formatter.VoidFormatter,
+ explain: formatter.VoidFormatter,
+ dateTime: formatter.VoidFormatter,
+ waitable: formatter.VoidFormatter,
+
+ /* TODO:*/
+ state: formatter.VoidFormatter,
+ 'status': formatter.VoidFormatter,
+ percent: formatter.VoidFormatter,
+ 'char': formatter.VoidFormatter,
+ limit: formatter.insurance.StandardLimitFormatter(),
+ deductible: formatter.VoidFormatter,
+ textarea: formatter.VoidFormatter,
+
+ // TODO: Refactor AcceptReject into a more generic
+ // formatted that accepts a map of values, and use that
+ // for both this, includeExclude, and anything else that
+ // requires exceptions to values
+ acceptReject: Base.use( formatter.AcceptReject )(),
+ includeExclude: formatter.VoidFormatter,
+
+ limitReject: formatter.insurance.StandardLimitFormatter
+ .use( formatter.AcceptReject )()
+ }
+ );
+};
+
diff --git a/test/event/FieldVisibilityEventHandlerTest.js b/test/event/FieldVisibilityEventHandlerTest.js
index 85b07c9..c683de8 100644
--- a/test/event/FieldVisibilityEventHandlerTest.js
+++ b/test/event/FieldVisibilityEventHandlerTest.js
@@ -19,7 +19,7 @@
* along with this program. If not, see .
*/
-const event = require( '../../' ).event;
+const event = require( '../../' ).client.event;
const expect = require( 'chai' ).expect;
const Class = require( 'easejs' ).Class;