module Pakyow::Validations::Presence

Validates that the value is present, or that a value is non-empty, non-nil, and not a string consisting of whitespace only characters. Example values that will not pass this validation:

@api public

Public Class Methods

message(**) click to toggle source
# File lib/pakyow/validations/presence.rb, line 18
def self.message(**)
  "cannot be blank"
end
valid?(value, **) click to toggle source
# File lib/pakyow/validations/presence.rb, line 22
def self.valid?(value, **)
  if value.is_a?(String)
    !value.strip.empty?
  elsif value.respond_to?(:empty?)
    !value.empty?
  else
    !!value
  end
end