var regula={bind:function(){},unbind:function(){},custom:function(){},compound:function(){},override:function(){},validate:function(){},Constraint:{},Group:{},DateFormat:{}};regula=function(){function b(){n={Default:{}}}function ct(){return this.checked}function ht(){return this.selectedIndex>0}function bi(n){return parseFloat(this.value)<=parseFloat(n.value)}function di(n){return parseFloat(this.value)>=parseFloat(n.value)}function ki(n){return this.value.replace(/\s/g,"")!=""&&parseFloat(this.value)<=parseFloat(n.max)&&parseFloat(this.value)>=parseFloat(n.min)}function ot(){return this.value.replace(/\s/g,"")!=""}function yi(){return this.value.replace(/\s/g,"")==""}function ci(n){var t;return t=typeof n.flags!="undefined"?new RegExp(n.regex.replace(/^\//,"").replace(/\/$/,""),n.flags):new RegExp(n.regex.replace(/^\//,"").replace(/\/$/,"")),t.test(this.value)}function hi(){return/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/i.test(this.value)}function li(){return/^[A-Za-z]+$/.test(this.value)}function vi(){return/^[0-9]+$/.test(this.value)}function ai(){return/^-?[0-9]+$/.test(this.value)}function er(){return/^-?([0-9]+(\.[0-9]+)?|\.[0-9]+)$/.test(this.value)}function fr(){return/^[0-9A-Za-z]+$/.test(this.value)}function or(){for(var i=[],t,n=0;n<this.elements.length;n++)t=this.elements[n],nt.call(t)||i.push(t);return i}function hr(n){var r=[],i=document.getElementById(n.field1),t=document.getElementById(n.field2);return i.value!=t.value&&(r=[i,t]),r}function nt(){var n=!0;return this.tagName&&(this.tagName.toLowerCase()=="select"?n=ht.call(this):this.type.toLowerCase()=="checkbox"||this.type.toLowerCase()=="radio"?n=ct.call(this):(this.tagName.toLowerCase()=="input"||this.tagName.toLowerCase()=="textarea")&&this.type.toLowerCase()!="button"&&(n=ot.call(this))),n}function sr(n){return this.value.length>=n.min&&this.value.length<=n.max}function ur(n){var r=this.value.replace(/\s/g,""),i=r.split(/\./),t=!1;return r.length>0&&(i.length==1&&(i[1]=""),t=n.integer>0?i[0].length<=n.integer:!0,n.fraction>0&&(t=t&&i[1].length<=n.fraction)),t}function d(n){var f={YMD:{Year:0,Month:1,Day:2},MDY:{Month:0,Day:1,Year:2},DMY:{Day:0,Month:1,Year:2}},i=f[n.format],r=n.separator;typeof n.separator=="undefined"&&(r=/\//.test(this.value)?"/":/\./.test(this.value)?".":/ /.test(this.value)?" ":/[^0-9]+/);var t=this.value.split(r),e=new Date(t[i.Year],t[i.Month]-1,t[i.Day]),u=new Date;return typeof n.date!="undefined"&&(t=n.date.split(r),u=new Date(t[i.Year],t[i.Month]-1,t[i.Day])),{dateToValidate:e,dateToTestAgainst:u}}function nr(n){var t=d.call(this,n);return t.dateToValidate<t.dateToTestAgainst}function gi(n){var t=d.call(this,n);return t.dateToValidate>t.dateToTestAgainst}function tr(n,i,r){for(var v=r.composingConstraints,p=[],f,c,y,a,l=0;l<v.length;l++){var e=v[l],o=u[e.constraintType],h={};for(f in e.params)e.params.hasOwnProperty(f)&&f!="__size__"&&s(h,f,e.params[f]);if(r.params.length>0)for(f in n)n.hasOwnProperty(f)&&f!="__size__"&&s(h,f,n[f]);c=at(i,this.id,o,h),c.constraintPassed||(y=lt(this.id,o,h),a={group:i,constraintName:o,custom:t[o].custom,compound:t[o].compound,constraintParameters:e.params,failingElements:c.failingElements,message:y},r.reportAsSingleViolation||(a.composingConstraintViolations=c.composingConstraintViolations||[]),p.push(a))}return p}function a(n,r,u){var f={successful:!0,message:"",data:null},e;return n.tagName.toLowerCase()!="form"||t[r].formSpecific?n.tagName.toLowerCase()!="form"&&t[r].formSpecific?f={successful:!1,message:i(n,r,"@"+r+" is a form constraint, but you are trying to bind it to a non-form element"),data:null}:(typeof n.type=="undefined"||n.type.toLowerCase()!="checkbox"&&n.type.toLowerCase()!="radio")&&r=="Checked"?f={successful:!1,message:i(n,r,"@"+r+" is only applicable to checkboxes and radio buttons. You are trying to bind it to an input element that is neither a checkbox nor a radio button."),data:null}:n.tagName.toLowerCase()!="select"&&r=="Selected"?f={successful:!1,message:i(n,r,"@"+r+" is only applicable to select boxes. You are trying to bind it to an input element that is not a select box."),data:null}:(e=ut(n,t[r],u),e.error?f={successful:!1,message:e.message,data:null}:f.data=u):f={successful:!1,message:i(n,r,"@"+r+" is not a form constraint, but you are trying to bind it to a form"),data:null},f}function ut(n,t,r){var s={error:!1,message:""},f,e,o;for(r.__size__<t.params.length&&(s={error:!0,message:i(n,u[t.constraintType],"@"+u[t.constraintType]+" expects at least "+t.params.length+" parameter(s). However, you have provided only "+r.__size__),data:null}),f=[],e=0;e<t.params.length;e++)o=t.params[e],typeof r[o]=="undefined"&&f.push(o);return f.length>0&&(s={error:!0,message:i(n,u[t.constraintType],"You seem to have provided some optional or required parameters for @"+u[t.constraintType]+", but you are still missing the following "+f.length+" required parameters(s): "+p(f,", ")),data:null}),s}function ft(t,i,r){var o="",a=new RegExp("^"+f[e.Default]+"$|^"+f[e.Default]+",|,"+f[e.Default]+",|,"+f[e.Default]+"$"),v={successful:!0,message:"",data:null},l,c,u,h;for(r.groups||s(r,"groups",f[e.Default]),o=r.groups.replace(/\s/g,""),a.test(o)||(o=f[e.Default]+","+o,r.groups=o),l=o.split(/,/),c=0;c<l.length;c++)u=l[c],n[u]||(h=-1,h=y.length>0?y.pop():pi++,e[u]=h,f[h]=u,n[u]={}),n[u][t.id]||(n[u][t.id]={}),n[u][t.id][i]=r}function w(n,t){var r=!1,i=0;while(!r&&i<n.length)r=t==n[i],i++;return r}function p(n,t){for(var r="",i=0;i<n.length;i++)r+=n[i]+t;return r.replace(new RegExp(t+"$"),"")}function s(n,t,i){n.__size__||(n.__size__=0),n[t]||n.__size__++,n[t]=i}function it(n){for(var t in n)if(n.hasOwnProperty(t))return!1;return!0}function o(n){var i="function received: {",t;for(t in n)n.hasOwnProperty(t)&&(typeof n[t]=="string"?i+=t+": "+n[t]+", ":n[t].length&&(i+=t+": ["+p(n[t],", ")+"], "));return i=i.replace(/, $/,"")+"}"}function i(n,t,i){var r="";return n!=null?(r=n.id,r+=t==""||t==null||t==undefined?": ":"."+t+": "):t!=""&&t!=null&&t!=undefined&&(r="@"+t+": "),r+i}function k(t,i){if(it(n[i][t])){delete n[i][t];if(it(n[i])){delete n[i];var r=e[i];delete e[i],delete f[r],y.push(r)}}}function rr(n,r){function e(n){return n?n.replace(/^\s+/,"").replace(/\s+$/,""):""}function f(n){return n[0]}function d(n){for(var i=n.str,o=n.delimiters.split(""),s=n.returnDelimiters||!1,e=n.returnEmptyTokens||!1,u=[],f=0,t,r=0;r<i.length;r++)w(o,i.charAt(r))&&(t=i.substring(f,r),t.length==0?e&&u.push(t):u.push(t),s&&u.push(i.charAt(r)),f=r+1);return f<i.length&&(t=i.substring(f,i.length),t.length==0?e&&u.push(t):u.push(t)),u}function nt(n){var t={successful:!0,message:"",data:null};while(n.length>0&&t.successful)t=et(n);return t}function et(t){var r={successful:!0,message:"",data:null},f=t.shift();return e(f).length==0&&(f=t.shift()),r=f=="@"?lt(t):{successful:!1,message:i(n,u,"Invalid constraint. Constraint definitions need to start with '@'")+" "+r.message,data:null}}function lt(r){var e={Between:"Range",Matches:"Pattern",Empty:"Blank",NotEmpty:"NotBlank",IsAlpha:"Alpha",IsNumeric:"Integer",IsAlphaNumeric:"AlphaNumeric"},f=at(r);return f.successful?(u=f.data,u=e[u]?e[u]:u,t[u]?(f=ht(r),f.successful&&(f=a(n,u,f.data),f.successful&&ft(n,u,f.data))):f={successful:!1,message:i(n,u,"I cannot find the specified constraint name. If this is a custom constraint, you need to define it before you bind to it")+" "+f.message,data:null}):f={successful:!1,message:i(n,u,"Invalid constraint name in constraint definition")+" "+f.message,data:null},f}function at(t){var s=e(t.shift()),r=o(s.charAt(0)),f;if(r.successful){f=1;while(f<s.length&&r.successful)r=h(s.charAt(f)),f++;r.successful&&(r.data=s)}else r={successful:!1,message:i(n,u,"Invalid starting character for constraint name. Can only include A-Z, a-z, and _")+" "+r.message,data:null};return r}function o(t){var r={successful:!0,message:"",data:null};return/[A-Za-z_]/.test(t)&&typeof t!="undefined"&&t!=null||(r={successful:!1,message:i(n,u,"Invalid starting character"),data:null}),r}function h(t){var r={successful:!0,message:"",data:null};return/[0-9A-Za-z_]/.test(t)||(r={successful:!1,message:i(n,u,"Invalid character in identifier. Can only include 0-9, A-Z, a-z, and _")+" "+r.message,data:null}),r}function ht(t){var r={successful:!0,message:"",data:{}},h,o;if(f(t)=="("){t.shift(),h={};if(f(t)==")")t.shift();else{r=l(t);if(r.successful){s(h,r.data.name,r.data.value),e(f(t)).length==0&&t.shift();while(t.length>0&&f(t)==","&&r.successful)t.shift(),r=l(t),r.successful&&(s(h,r.data.name,r.data.value),e(f(t)).length==0&&t.shift());r.successful&&(o=t.shift(),e(o).length==0&&(o=t.shift()),o!=")"?r={successful:!1,message:i(n,u,"Cannot find matching closing ) in parameter list")+" "+r.message,data:null}:r.data=h)}else r={successful:!1,message:i(n,u,"Invalid parameter definition")+" "+r.message,data:null}}}else f(t)!==undefined&&f(t)!="@"&&(r={successful:!1,message:i(n,u,"Unexpected character '"+f(t)+"' after constraint definition")+" "+r.message,data:null});return r}function l(t){var r=st(t),e,f;return r.successful?(e=r.data,f=t.shift(),f=="="?(r=ot(t),r.successful?r.data={name:e,value:r.data}:r={successful:!1,message:i(n,u,"Invalid parameter value")+" "+r.message,data:null}):(t.unshift(f),r={successful:!1,message:i(n,u,"'=' expected after parameter name "+r.message),data:null})):r={successful:!1,message:i(n,u,"Invalid parameter name. You might have unmatched parentheses")+" "+r.message,data:null},r}function st(t){var f=e(t.shift()),r,s;f.length==0&&(f=t.shift()),r={successful:!1,message:i(n,u,"Invalid starting character for parameter name. Can only include A-Z, a-z, and _"),data:null};if(typeof f!="undefined"){r=o(f.charAt(0));if(r.successful){s=1;while(s<f.length&&r.successful)r=h(f.charAt(s)),s++;r.successful&&(r.data=f)}else r={successful:!1,message:i(n,u,"Invalid starting character for parameter name. Can only include A-Z, a-z, and _")+" "+r.message,data:null}}return r}function ot(t){var r,o;return e(f(t)).length==0&&t.shift(),r={successful:!0,message:"",data:[]},f(t)==")"?r={successful:!1,message:i(n,u,"Parameter value expected")+" "+r.message,data:null}:(r=ct(t),o=r.message,r.successful||(r=g(t),r.message=r.message+" "+o,o=r.message,r.successful||(r=tt(t),r.message=r.message+" "+o,o=r.message,r.successful||(r=ut(t),r.message=r.message+" "+o,o=r.message,r.successful||(r=rt(t),r.message=r.message+" "+o,o=r.message,r.successful||(r={successful:!1,message:i(n,u,"Parameter value must be a number, quoted string, regular expression, or a boolean")+" "+o,data:null})))))),r}function ct(t){var r=vt(t);return r.successful||(r=c(t),r.successful||(r={successful:!1,message:i(n,u,"Parameter value is not a number")+" "+r.message,data:null})),r}function vt(t){var f=t.shift(),r={successful:!0,message:"",data:null};return f=="-"?(r=c(t),r.successful&&(r.data=f+r.data)):(t.unshift(f),r={successful:!1,message:i(n,u,"Not a negative number"),data:null}),r}function c(t){var r=null,e;return f(t)!="."?(r=b(t),f(t)=="."&&(e=r.data,r=v(t),r.successful&&(r.data=e+r.data))):r=v(t),r.successful||(r={successful:!1,message:i(n,u,"Not a positive number")+" "+r.message,data:null}),r}function v(t){var f=t.shift(),r=b(t);return r.successful?r.data=f+r.data:r={successful:!1,message:i(n,u,"Not a valid fraction"),data:null},r}function b(t){var f=e(t.shift()),r=k(f.charAt(0)),o;if(r.successful){o=1;while(o<f.length&&r.successful)r=k(f.charAt(o)),o++;r.successful&&(r.data=f)}else t.unshift(f),r={successful:!1,message:i(n,u,"Not a valid integer")+" "+r.message,data:[]};return r}function k(t){var r={successful:!0,message:"",data:null};return/[0-9]/.test(t)||(r={successful:!1,message:i(n,u,"Not a valid digit"),data:null}),r}function g(t){var s=t.shift(),o="",r={successful:!0,message:"",data:null},e;if(s=='"'){e=!1;while(t.length>0&&r.successful&&!e)f(t)=='"'?(e=!0,t.shift()):(r=y(t),o+=r.data);e||(r={successful:!1,message:i(n,u,"Unterminated string literal"),data:null})}else t.unshift(s),r={successful:!1,message:i(n,u,"Invalid quoted string"),data:null};return r.successful=r.successful&&e,r.data=o,r}function y(n){var i="",t=n.shift();return t=="\\"&&(i=n.shift()),{successful:!0,message:"",data:t+i}}function tt(t){var o="",s=t.shift(),r={successful:!0,message:"",data:null},e;if(s=="/"){o=s,e=!1;while(t.length>0&&r.successful&&!e)f(t)=="/"?(o+=t.shift(),e=!0):(r=y(t),o+=r.data);e||(r={successful:!1,message:i(n,u,"Unterminated regex literal"),data:null})}else t.unshift(s),r={successful:!1,message:i(n,u,"Not a regular expression"),data:null};return r.successful=r.successful&&e,r.data=o,r}function ut(t){var r=t.shift(),f={successful:!0,message:"",data:null};return e(r)=="true"||e(r)=="false"?f={successful:!0,message:"",data:r}:(t.unshift(r),f={successful:!1,message:i(n,u,"Not a boolean"),data:null}),f}function rt(t){var s="",o=t.shift(),r={successful:!0,message:"",data:null};if(o=="["){e(f(t)).length==0&&t.shift(),r=f(t)=="]"?{successful:!0,message:"",data:""}:p(t);if(r.successful){s=r.data,e(f(t)).length==0&&t.shift();while(t.length>0&&f(t)==","&&r.successful)t.shift(),r=p(t),s+=","+r.data,e(f(t)).length==0&&t.shift();r.data=s,o=t.shift(),e(o).length==0&&t.shift(),o!="]"&&(r={successful:!1,message:i(n,u,"Cannot find matching closing ] in group definition")+" "+r.message,data:null})}else r={successful:!1,message:i(n,u,"Invalid group definition")+" "+r.message,data:null}}else t.unshift(o),r={successful:!1,message:i(n,u,"Not a valid group definition"),data:null};return r}function p(t){var r={successful:!0,message:"",data:""},f=e(t.shift()),s;f.length==0&&(f=t.shift()),r=o(f.charAt(0));if(r.successful){s=1;while(s<f.length&&r.successful)r=h(f.charAt(s)),s++;r.successful&&(r.data=f)}else r={successful:!1,message:i(n,u,"Invalid starting character for group name. Can only include A-Z, a-z, and _")+" "+r.message,data:null};return r}var u="",it=d({str:e(r.replace(/\s*\n\s*/g,"")),delimiters:'@()[]=,"\\/-\\.',returnDelimiters:!0,returnEmptyTokens:!1});return nt(it)}function ir(n){if(!n)throw"regula.custom expects options";var i=n.name,s=n.formSpecific||!1,f=n.validator,o=n.params||[],e=n.defaultMessage||"";if(i){if(typeof i!="string")throw"regula.custom expects the name attribute in the options argument to be a string";else if(i.replace(/\s/g,"").length==0)throw"regula.custom cannot accept an empty string for the name attribute in the options argument";}else throw"regula.custom expects a name attribute in the options argument";if(typeof s!="boolean")throw"regula.custom expects the formSpecific attribute in the options argument to be a boolean";if(f){if(typeof f!="function")throw"regula.custom expects the validator attribute in the options argument to be a function";}else throw"regula.custom expects a validator attribute in the options argument";if(o.constructor.toString().indexOf("Array")<0)throw"regula.custom expects the params attribute in the options argument to be an array";if(typeof e!="string")throw"regula.custom expects the defaultMessage attribute in the options argument to be a string";if(t[i])throw"There is already a constraint called "+i+". If you wish to override this constraint, use regula.override";else r[i]=v,u[v++]=i,t[i]={formSpecific:s,validator:f,constraintType:r[i],custom:!0,compound:!1,params:o,defaultMessage:e}}function si(n){if(!n)throw"regula.compound expects options";var i=n.name,f=n.constraints||[],s=n.formSpecific||!1,h=n.defaultMessage||"",e=n.params||[],o=typeof n.reportAsSingleViolation=="undefined"?!1:n.reportAsSingleViolation;if(!i)throw"regula.compound expects a name attribute in the options argument";if(typeof i!="string")throw"regula.compound expects name to be a string parameter";if(e.constructor.toString().indexOf("Array")<0)throw"regula.compound expects the params attribute in the options argument to be an array";if(f.length==0)throw"regula.compound expects an array of composing constraints under a constraints attribute in the options argument";if(t[i])throw"regula.compound: There is already a constraint called "+i+". If you wish to override this constraint, use regula.override";rt(i,f,e),r[i]=v,u[v++]=i,t[i]={formSpecific:s,constraintType:r[i],custom:!0,compound:!0,params:e,reportAsSingleViolation:o,composingConstraints:f,defaultMessage:h,validator:tr},st(i,f)}function st(n,i){var o=c.getNodeByType(r[n]),f,s,e;for(o==null&&(c.addNode(r[n],null),o=c.getNodeByType(r[n])),f=0;f<i.length;f++)s=u[i[f].constraintType],e=t[s],e.compound&&c.addNode(e.constraintType,o)}function rt(n,i,r){for(var a=[],o,h,c,f=0;f<i.length;f++)if(i[f].constraintType)a.push(t[u[i[f].constraintType]]);else throw"In compound constraint "+n+": A composing constraint has no constraint type specified.";for(f=0;f<i.length;f++){var e=i[f],v=u[e.constraintType],l={};e.params=e.params||{__size__:0};for(o in e.params)e.params.hasOwnProperty(o)&&s(l,o,e.params[o]);for(h=0;h<r.length;h++)s(l,r[h],null);c=ut(null,t[v],l);if(c.error)throw"In compound constraint "+n+": "+c.message;}}function ri(n){var i,e;if(!n)throw"regula.override expects options";if(typeof n.constraintType=="undefined")throw"regula.override expects a constraintType attribute in the options argument";i=u[n.constraintType];if(typeof r[i]=="undefined")throw"regula.override: A constraint called "+i+" has not been defined, so I cannot override it";else{var h=t[i].custom?n.formSpecific||t[i].formSpecific:t[i].formSpecific,s=t[i].custom&&!t[i].compound?n.validator||t[i].validator:t[i].validator,o=t[i].custom?n.params||t[i].params:t[i].params,l=n.defaultMessage||t[i].defaultMessage,a=t[i].compound,f=n.constraints||t[i].constraints;if(typeof h!="boolean")throw"regula.override expects the formSpecific attribute in the options argument to be a boolean";if(typeof s!="function")throw"regula.override expects the validator attribute in the options argument to be a function";if(o.constructor.toString().indexOf("Array")<0)throw"regula.override expects the params attribute in the options argument to be an array";if(typeof l!="string")throw"regula.override expects the defaultMessage attribute in the options argument to be a string";if(a){rt(i,f,o),st(i,f),e=c.cycleExists(c.getNodeByType(n.constraintType));if(e.cycleExists)throw"regula.override: The overriding composing-constraints you have specified have created a cyclic composition: "+e.path;}t[i]={formSpecific:h,constraintType:r[i],custom:!0,compound:a,params:o,composingConstraints:f,defaultMessage:l,validator:s}}}function fi(t){var e,f,r,o,i;if(typeof t!="undefined"&&t){if(typeof t.id=="undefined")throw"regula.unbind requires an id if options are provided";e=t.id,f=t.constraints||[];if(f.length==0)for(i in n)n.hasOwnProperty(i)&&k(e,i);else for(r=0;r<f.length;r++){o=f[r],delete n[i][element.id][u[o]];for(i in n)n.hasOwnProperty(i)&&k(e,i)}}else b()}function oi(t){var i,r;n||b(),i={successful:!0,message:"",data:null},typeof t!="undefined"&&t?(r=t.elements,i=typeof r!="undefined"&&r?gt(t,r):g(t)):(b(),i=tt([]));if(!i.successful)throw i.message;}function gt(n,t){var i={successful:!0},r=0;while(i.successful&&r<t.length)n.element=t[r],i=g(n),i.successful||(i.message="regula.bind: Element "+r+" of "+t.length+" failed: "+i.message),r++;return i}function tt(n){var u,r,f,t,i,e;u=typeof n!="undefined"&&n&&n.length!=0?n:wt(document.body,"*","data-constraints"),r={successful:!0,message:"",data:null},f=0;while(f<u.length&&r.successful)t=u[f],i=t.tagName.toLowerCase(),i!="form"&&i!="select"&&i!="textarea"&&i!="input"&&(r={successful:!1,message:i+"#"+t.id+" is not an input, select, or form element! Validation constraints can only be attached to input, select, or form elements.",data:null}),t.id||(t.id="regula-generated-"+Math.floor(Math.random()*1e6)),e=t.getAttribute("data-constraints"),r=rr(t,e),f++;return r}function g(n){var i={successful:!0,message:"",data:null},t=n.element,f=n.constraints||[],r=t?t.tagName.toLowerCase():null,u;if(t)if(typeof t!="object")i={successful:!1,message:"regula.bind: element attribute is of unexpected type: "+typeof t+" "+o(n),data:null};else if(r!="form"&&r!="select"&&r!="textarea"&&r!="input")i={successful:!1,message:r+"#"+t.id+" is not an input, select, or form element! Validation constraints can only be attached to input, select, or form elements "+o(n),data:null};else if(f.length>0){u=0;while(u<f.length&&i.successful)i=ii(f[u],n),u++}else i=tt([t]);else i={successful:!1,message:"regula.bind expects a non-null element attribute in the options argument "+o(n),data:null};return i}function ii(t,i){function nt(n,t){for(var f={},u=[],r,i=0;i<n.length;i++)u.push(n[i]),f[n[i]]=!0;for(r=0;r<t.length;r++)f[t[r]]||u.push(t[r]);return u}function rt(n,t){for(var r=[],i=0;i<t.length;i++)w(n,t[i])||r.push(t[i]);return r}function g(t,i,r){var l=n[f[e.Default]][t.id][u[i]].groups.split(/,/),o=[],h,s,c;for(r.groups?o=r.groups.split(/,/):o.push(f[e.Default]),w(o,f[e.Default])||o.push(f[e.Default]),h=rt(o,nt(l,o)),s=0;s<h.length;s++)c=h[s],delete n[c][t.id][u[i]],k(t.id,c)}var c={successful:!0,message:"",data:null},v=i.element,tt=t.overwriteConstraint||!1,it=t.overwriteParameters||!1,y=t.constraintType,r=t.params||{},l={__size__:0},b,p,d,h;if(typeof y=="undefined")c={successful:!1,message:"regula.bind expects a valid constraint type for each constraint in constraints attribute of the options argument. "+o(i),data:null};else if(r&&r.groups)if(typeof r.groups=="object"&&r.groups.length!=undefined){b="",p=0;while(p<r.groups.length&&c.successful)typeof r.groups[p]=="string"?b+=r.groups[p]+",":f[r.groups[p]]?b+=f[r.groups[p]]+",":c={successful:!1,message:"Invalid group "+r.groups[p]+" "+o(i),data:null},p++;c.successful&&(b=b.replace(/,$/,""),r.groups=b)}else c={successful:!1,message:"The groups parameter must be an array of enums or strings "+o(i),data:null};if(c.successful){if(n[f[e.Default]][v.id]&&n[f[e.Default]][v.id][u[y]])if(tt){for(h in r)r.hasOwnProperty(h)&&s(l,h,r[h]);c=a(v,u[y],l),c.successful&&g(v,y,r)}else{d=n[f[e.Default]][v.id][u[y]];for(h in d)d.hasOwnProperty(h)&&s(l,h,d[h]);if(it){for(h in r)r.hasOwnProperty(h)&&s(l,h,r[h]);c=a(v,u[y],l),c.successful&&g(v,y,l)}else for(h in r)r.hasOwnProperty(h)&&(d[h]||s(l,h,r[h]))}else{for(h in r)r.hasOwnProperty(h)&&s(l,h,r[h]);c=a(v,u[y],l)}c.successful&&ft(v,u[y],l)}return c}function ti(n){var t=null,i;if(typeof n!="undefined"&&typeof n.elements!="undefined")if(n.elements instanceof Array)for(t=[],i=0;i<n.elements.length;i++)n.elementId=n.elements[i].id,t=t.concat(et(n));else throw"regula.validate: If an elements attribute is provided, it must be an array.";else t=et(n);return t}function et(n){function i(n){var u=n.groups||null,i=n.elementId||null,r=n.constraintType||null,t="";return t+=u==null?"0":"1",t+=i==null?"0":"1",t+=r==null?"0":"1"}var r={"000":ni,"001":dt,"010":pt,"011":ei,"100":ui,"101":kt,"110":yt,"111":bt},t;l={},n&&typeof n!="undefined"||(n={}),n.independent==undefined&&(n.independent=!0),n.constraintType&&(n.constraintType=u[n.constraintType]);if(n.groups)for(t=0;t<n.groups.length;t++)n.groups[t]=f[n.groups[t]];return r[i(n)](n)}function ni(){var o=[],r,i,t,f,u,e;for(r in n)if(n.hasOwnProperty(r)){i=n[r];for(t in i)if(i.hasOwnProperty(t))if(document.getElementById(t)){f=i[t];for(u in f)f.hasOwnProperty(u)&&(e=h(r,t,u),e&&o.push(e))}else delete i[t]}return o}function dt(t){var l=[],s=!1,f,i,r,c,e;for(f in n)if(n.hasOwnProperty(f)){i=n[f];for(r in i)i.hasOwnProperty(r)&&(c=i[r],c[t.constraintType]&&(s=!0,e=h(f,r,t.constraintType),e&&l.push(e)))}if(!s)throw"Constraint "+u[t.constraintType]+" has not been bound to any element. "+o(t);return l}function pt(t){var c=[],s=!1,i,e,r,u,f;for(i in n)if(n.hasOwnProperty(i)){e=n[i];if(e[t.elementId]){s=!0,r=e[t.elementId];for(u in r)r.hasOwnProperty(u)&&(f=h(i,t.elementId,u),f&&c.push(f))}}if(!s)throw"No constraints have been bound to element with id "+t.elementId+". "+o(t);return c}function ei(t){var f=[],s=!1,e=!1,i,c,r,u;for(i in n)n.hasOwnProperty(i)&&(c=n[i],r=c[t.elementId],r&&(s=!0,r[t.constraintType]&&(e=!0,u=h(i,t.elementId,t.constraintType),u&&f.push(u))));if(!s||!e)throw"No element with id "+t.elementId+" was found with the constraint "+t.constraintType+" bound to it. "+o(t);return f}function ui(t){var u=[],c=0,a=!0,l,i,r,s,f,e;while(c<t.groups.length&&a){l=t.groups[c],i=n[l];if(i){for(r in i)if(i.hasOwnProperty(r)){s=i[r];for(f in s)s.hasOwnProperty(f)&&(e=h(l,r,f),e&&u.push(e))}}else throw"Undefined group in group list. "+o(t);c++,a=u.length==0||t.independent&&u.length!=0}return u}function kt(t){var f=[],c=0,l=!0,r,i,s,u,a,e;while(c<t.groups.length&&l){r=t.groups[c],i=n[r];if(i){s=!1;for(u in i)i.hasOwnProperty(u)&&(a=i[u],a[t.constraintType]&&(s=!0,e=h(r,u,t.constraintType),e&&f.push(e)));if(!s)throw"Constraint "+t.constraintType+" has not been bound to any element under group "+r+". "+o(t);}else throw"Undefined group in group list. "+o(t);c++,l=f.length==0||t.independent&&f.length!=0}return f}function yt(t){var u=[],s=[],c=0,a=!0,r,e,i,f,l;while(c<t.groups.length&&a){r=t.groups[c],e=n[r];if(e){i=e[t.elementId];if(i)for(f in i)i.hasOwnProperty(f)&&(l=h(r,t.elementId,f),l&&u.push(l));else s.push(r)}else throw"Undefined group in group list. "+o(t);c++,a=u.length==0||t.independent&&u.length!=0}if(s.length>0)throw"No element with id "+t.elementId+" was found in the following group(s): ["+p(s,",").replace(/,/g,", ")+"]. "+o(t);return u}function bt(n){var t=[],r=0,u=!0,f,i;while(r<n.groups.length&&u)f=n.groups[r],i=h(f,n.elementId,n.constraintType),i&&t.push(i),r++,u=t.length==0||n.independent&&t.length!=0;return t}function h(i,r,u){var h,c=n[i],o,f,e,s;if(!c)throw"Undefined group in group list";o=c[r],l[r]||(l[r]={});if(!l[r][u])if(o){f=o[u];if(f)e=at(i,r,u,f),e.constraintPassed||(s=lt(r,u,f),h={group:i,constraintName:u,formSpecific:t[u].formSpecific,custom:t[u].custom,compound:t[u].compound,composingConstraintViolations:e.composingConstraintViolations||[],constraintParameters:f,failingElements:e.failingElements,message:s});else throw u+" in group "+i+" hasn't been bound to the element with id "+r;}else throw"No constraints have been defined for the element with id: "+r+" in group "+i;return h}function at(n,i,r,u){var f=!1,o=[],e=document.getElementById(i),h=[],s;return t[r].formSpecific?(o=t[r].validator.call(e,u),f=o.length==0):t[r].compound?(h=t[r].validator.call(e,u,n,t[r]),f=h.length==0,f||o.push(e)):(f=t[r].validator.call(e,u),f||o.push(e)),l[i][r]=!0,s={constraintPassed:f,failingElements:o},t[r].reportAsSingleViolation||(s.composingConstraintViolations=h),s}function lt(n,i,r){var o=document.getElementById(n),u="",f,s,e;u=r.message?r.message:r.msg?r.msg:t[i].defaultMessage;for(f in r)r.hasOwnProperty(f)&&(s=new RegExp("{"+f+"}","g"),u=u.replace(s,r[f]));return/{label}/.test(u)&&(e=vt[o.tagName.toLowerCase()],e||(e=vt[o.type.toLowerCase()]),u=u.replace(/{label}/,e),u=u.replace(/{flags}/g,"")),u=u.replace(/\\\"/g,'"')}var wt=function(n,t,i,r){for(var o=t=="*"&&n.all?n.all:n.getElementsByTagName(t),h=[],s=typeof r!="undefined"?new RegExp("(^|\\s)"+r+"(\\s|$)"):null,u,f,e=0;e<o.length;e++)u=o[e],f=u.getAttribute&&u.getAttribute(i),typeof f=="string"&&f.length>0&&(typeof r=="undefined"||s&&s.test(f))&&h.push(u);return h},e={Default:0},f={0:"Default"},y=[],r={Checked:0,Selected:1,Max:2,Min:3,Range:4,Between:4,NotBlank:5,NotEmpty:5,Blank:6,Empty:6,Pattern:7,Matches:7,Email:8,Alpha:9,IsAlpha:9,Numeric:10,IsNumeric:12,AlphaNumeric:11,IsAlphaNumeric:11,Integer:12,Real:13,CompletelyFilled:14,PasswordsMatch:15,Required:16,Length:17,Digits:18,Past:19,Future:20},u={0:"Checked",1:"Selected",2:"Max",3:"Min",4:"Range",5:"NotBlank",6:"Blank",7:"Pattern",8:"Email",9:"Alpha",10:"Numeric",11:"AlphaNumeric",12:"Integer",13:"Real",14:"CompletelyFilled",15:"PasswordsMatch",16:"Required",17:"Length",18:"Digits",19:"Past",20:"Future"},wi={DMY:"DMY",MDY:"MDY",YMD:"YMD"},vt={form:"The form",select:"The select box",textarea:"The text area",checkbox:"The checkbox",radio:"The radio button",text:"The text field",password:"The password"},v=21,pi=1,t={Checked:{formSpecific:!1,validator:ct,constraintType:r.Checked,custom:!1,compound:!1,params:[],defaultMessage:"{label} needs to be checked."},Selected:{formSpecific:!1,validator:ht,constraintType:r.Selected,custom:!1,compound:!1,params:[],defaultMessage:"{label} needs to be selected."},Max:{formSpecific:!1,validator:bi,constraintType:r.Max,custom:!1,compound:!1,params:["value"],defaultMessage:"{label} needs to be lesser than or equal to {value}."},Min:{formSpecific:!1,validator:di,constraintType:r.Min,custom:!1,compound:!1,params:["value"],defaultMessage:"{label} needs to be greater than or equal to {value}."},Range:{formSpecific:!1,validator:ki,constraintType:r.Range,custom:!1,compound:!1,params:["min","max"],defaultMessage:"{label} needs to be between {min} and {max}."},NotBlank:{formSpecific:!1,validator:ot,constraintType:r.NotBlank,custom:!1,compound:!1,params:[],defaultMessage:"{label} cannot be blank."},Blank:{formSpecific:!1,validator:yi,constraintType:r.Blank,custom:!1,compound:!1,params:[],defaultMessage:"{label} needs to be blank."},Pattern:{formSpecific:!1,validator:ci,constraintType:r.Pattern,custom:!1,compound:!1,params:["regex"],defaultMessage:"{label} needs to match {regex}{flags}."},Email:{formSpecific:!1,validator:hi,constraintType:r.Email,custom:!1,compound:!1,params:[],defaultMessage:"{label} is not a valid email."},Alpha:{formSpecific:!1,validator:li,constraintType:r.Alpha,custom:!1,compound:!1,params:[],defaultMessage:"{label} can only contain letters."},Numeric:{formSpecific:!1,validator:vi,constraintType:r.Numeric,custom:!1,compound:!1,params:[],defaultMessage:"{label} can only contain numbers."},AlphaNumeric:{formSpecific:!1,validator:fr,constraintType:r.AlphaNumeric,custom:!1,compound:!1,params:[],defaultMessage:"{label} can only contain numbers and letters."},Integer:{formSpecific:!1,validator:ai,constraintType:r.Integer,custom:!1,compound:!1,params:[],defaultMessage:"{label} must be an integer."},Real:{formSpecific:!1,validator:er,constraintType:r.Real,custom:!1,compound:!1,params:[],defaultMessage:"{label} must be a real number."},CompletelyFilled:{formSpecific:!0,validator:or,constraintType:r.CompletelyFilled,custom:!1,compound:!1,params:[],defaultMessage:"{label} must be completely filled."},PasswordsMatch:{formSpecific:!0,validator:hr,constraintType:r.PasswordsMatch,custom:!1,compound:!1,params:["field1","field2"],defaultMessage:"Passwords do not match."},Required:{formSpecific:!1,validator:nt,constraintType:r.Required,custom:!1,compound:!1,params:[],defaultMessage:"{label} is required."},Length:{formSpecific:!1,validator:sr,constraintType:r.Length,custom:!1,compound:!1,params:["min","max"],defaultMessage:"{label} length must be between {min} and {max}."},Digits:{formSpecific:!1,validator:ur,constraintType:r.Digits,custom:!1,compound:!1,params:["integer","fraction"],defaultMessage:"{label} must have up to {integer} digits and {fraction} fractional digits."},Past:{formSpecific:!1,validator:nr,constraintType:r.Past,custom:!1,compound:!1,params:["format"],defaultMessage:"{label} must be in the past."},Future:{formSpecific:!1,validator:gi,constraintType:r.Future,custom:!1,compound:!1,params:["format"],defaultMessage:"{label} must be in the future."}},c={addNode:function(){},getNodeByType:function(){},cycleExists:function(){},getRoot:function(){}},n,l;return c=function(){function e(i,r){var f=t[i]==null?{visited:!1,name:u[i],type:i,children:[]}:t[i];r==null?n.children[n.children.length]=f:r.children[r.children.length]=f,t[i]=f}function o(n){return t[n]}function f(n){var t=function(n,t){var r={cycleExists:!1,path:t},i;if(n.visited)r={cycleExists:!0,path:t};else{n.visited=!0,i=0;while(i<n.children.length&&!r.cycleExists)r=arguments.callee(n.children[i],t+"."+n.children[i].name),i++}return r}(n,n.name);return t.cycleExists||i(),t}function i(){(function(n){n.visited=!1;for(var t=0;t<n.children.length;t++)arguments.callee(n.children[t])})(n)}function r(){return n}var t={},n={visited:!1,name:"RootNode",type:-1,children:[]};return{addNode:e,getNodeByType:o,cycleExists:f,getRoot:r}}(),n=null,l={},{bind:oi,unbind:fi,validate:ti,custom:ir,compound:si,override:ri,Constraint:r,Group:e,DateFormat:wi}}()
