class Toolchain::Validations::Validators::Presence
Validates the presence of an attribute. If the attribute is either `nil` or `“”` (empty String) it is considered invalid.
@example
class User::Creator validates :name, presence: { message: "is required" } end
Public Instance Methods
validate()
click to toggle source
# File lib/toolchain/validations/validators/presence.rb, line 15 def validate errors.add(key_path, message || "can't be blank") if blank? end
Private Instance Methods
blank?()
click to toggle source
# File lib/toolchain/validations/validators/presence.rb, line 21 def blank? [nil, ""].include?(value) end