Skip to content

Instantly share code, notes, and snippets.

@teamon
Created August 2, 2008 20:02
Show Gist options
  • Save teamon/3771 to your computer and use it in GitHub Desktop.
Save teamon/3771 to your computer and use it in GitHub Desktop.
undefined
if defined?(Validate)
module Validate
module AutoValidate
alias :orig_auto_generate_validations, :auto_generate_validations
def auto_generate_validations(property)
orig_auto_generate_validations(property)
return unless property.options[:auto_validation]
if property.type.ancestors.include?(Types::Enum)
validates_within property.name, options_with_message({:set => property.type.flag_map.values}, property, :within)
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment