Class: Castkit::Generators::Validator

Inherits:
Base
  • Object
show all
Defined in:
lib/generators/validator.rb

Overview

Generator for creating a new Castkit validator.

Validators are responsible for asserting that a given value conforms to a rule. They are typically used inside a type’s ‘#validate!` method or within custom contract logic.

Example usage:

$ castkit generate validator Money

Generates:

  • lib/castkit/validators/money.rb

  • spec/castkit/validators/money_spec.rb

These files scaffold a ‘Castkit::Validators::Money` class with a `#call` method and a corresponding RSpec test suite.

See Also:

Method Summary

Methods inherited from Base

component, #create_component, #create_spec, source_root