(function(){var e=function(e){var t=this;e.require().script("mvc/model").done(function(){var n=function(){var t=function(t,n,r){r||(r=n,n={}),n=n||{},t=e.makeArray(t);if(n.testIf&&!n.testIf.call(this))return;var i=this;e.each(t,function(e,t){i.validations[t]||(i.validations[t]=[]),i.validations[t].push(function(){var e=r.call(this,this[t]);return e===undefined?undefined:n.message||e})})};e.extend(e.Model,{validate:t,validationMessages:{format:"is invalid",inclusion:"is not a valid option (perhaps out of range)",lengthShort:"is too short",lengthLong:"is too long",presence:"can't be empty",range:"is out of range"},validateFormatOf:function(e,n,r){t.call(this,e,r,function(e){if(typeof e!="undefined"&&e!=""&&(e+"").match(n)==null)return this.Class.validationMessages.format})},validateInclusionOf:function(n,r,i){t.call(this,n,i,function(t){if(typeof t=="undefined")return;if(e.grep(r,function(e){return e==t}).length==0)return this.Class.validationMessages.inclusion})},validateLengthOf:function(e,n,r,i){t.call(this,e,i,function(e){if(typeof e=="undefined"&&n>0||e.length<n)return this.Class.validationMessages.lengthShort+" (min="+n+")";if(typeof e!="undefined"&&e.length>r)return this.Class.validationMessages.lengthLong+" (max="+r+")"})},validatePresenceOf:function(e,n){t.call(this,e,n,function(e){if(typeof e=="undefined"||e==""||e===null)return this.Class.validationMessages.presence})},validateRangeOf:function(e,n,r,i){t.call(this,e,i,function(e){if(typeof e!="undefined"&&e<n||e>r)return this.Class.validationMessages.range+" ["+n+","+r+"]"})}})};n(),t.resolveWith(n)})};dispatch("mvc/model.validations").containing(e).to("Foundry/2.1 Modules")})();