Validator
继承于 Validator
class MyValidator < ActiveModel::Validator
# 继承于 Validator,需要实现 validate
def validate(record)
record # => The person instance being validated
options # => Any non-standard options passed to validates_with
end
end
class Person
include ActiveModel::Validations
# 调用方式
validates_with MyValidator
end继承于 EachValidator
最后更新于