class Contentful::Validations::LambdaValidation
Class to define lambda validations
Public Class Methods
new(name, fn)
click to toggle source
# File lib/contentful_model/validations/lambda_validation.rb, line 5 def initialize(name, fn) @name = name fail "#{name}: Validator function or Proc is required" unless fn.is_a?(Proc) @validator = fn end
Public Instance Methods
validate(entry)
click to toggle source
# File lib/contentful_model/validations/lambda_validation.rb, line 11 def validate(entry) return ["#{@name}: validation not met"] unless @validator[entry] [] end