Class: Yes::Core::Commands::Validator Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/yes/core/commands/validator.rb

Overview

This class is abstract.

Subclass and override Validator.call to implement a custom command validator.

Examples:

class MyCommandValidator < Yes::Core::Commands::Validator
  def self.call(command)
    raise CommandInvalid, 'Name is required' if command.payload[:name].blank?
  end
end

Constant Summary collapse

CommandInvalid =
Class.new(Yes::Core::Error)

Class Method Summary collapse

Class Method Details

.call(command) ⇒ Object

Validates the given command. Must be implemented by subclasses.

Parameters:

Raises:

  • (CommandInvalid)

    if command is invalid

  • (NotImplementedError)

    if not overridden



22
23
24
# File 'lib/yes/core/commands/validator.rb', line 22

def self.call(command)
  raise NotImplementedError
end