Rails -- validations
I know that the validates
method can validate presence, length, format, uniqueness, and confirmation. However, sometimes I see people just setting these values to true/false, while other times they are more specific and pass in a hash that specifies the exact constraints (e.g. 开发者_JAVA百科:maximum => 50
for length or case_sensitive => false
for uniqueness). Is there a way that I can view a list of all the specifications that can be added to each of these validation tests?
This is right in the Rails API for ActiveModel::Validations::HelperMethods.
A list of validators and their respective options can be found here: http://api.rubyonrails.org/classes/ActiveModel/Validations/HelperMethods.html
精彩评论