Class: GraphQL::Schema::Validator::AllowBlankValidator
- Inherits:
 - 
      GraphQL::Schema::Validator
      
        
- Object
 - GraphQL::Schema::Validator
 - GraphQL::Schema::Validator::AllowBlankValidator
 
 
- Defined in:
 - lib/graphql/schema/validator/allow_blank_validator.rb
 
Overview
Use this to specifically reject values that respond to .blank? and respond truthy for that method.
Constant Summary
Constants included from EmptyObjects
EmptyObjects::EMPTY_ARRAY, EmptyObjects::EMPTY_HASH
Instance Attribute Summary
Attributes inherited from GraphQL::Schema::Validator
Instance Method Summary collapse
- 
  
    
      #initialize(allow_blank_positional, allow_blank: nil, message: "%{validated} can't be blank", **default_options)  ⇒ AllowBlankValidator 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of AllowBlankValidator.
 - 
  
    
      #validate(_object, _context, value)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
 
Methods inherited from GraphQL::Schema::Validator
from_config, install, #partial_format, #permitted_empty_value?, uninstall, validate!
Constructor Details
#initialize(allow_blank_positional, allow_blank: nil, message: "%{validated} can't be blank", **default_options) ⇒ AllowBlankValidator
Returns a new instance of AllowBlankValidator.
      11 12 13 14 15  | 
    
      # File 'lib/graphql/schema/validator/allow_blank_validator.rb', line 11 def initialize(allow_blank_positional, allow_blank: nil, message: "%{validated} can't be blank", **) @message = super(**) @allow_blank = allow_blank.nil? ? allow_blank_positional : allow_blank end  | 
  
Instance Method Details
#validate(_object, _context, value) ⇒ Object
      17 18 19 20 21 22 23 24 25  | 
    
      # File 'lib/graphql/schema/validator/allow_blank_validator.rb', line 17 def validate(_object, _context, value) if value.respond_to?(:blank?) && value.blank? if (value.nil? && @allow_null) || @allow_blank # pass else @message end end end  |