Sha256: 47567f8c5a5aa8b7bf848cbda4706f7c503c182887b259d056b20fef1ee7a986

Contents?: true

Size: 502 Bytes

Versions: 4

Compression:

Stored size: 502 Bytes

Contents

module FactoryBotRails
  class FactoryValidator
    def initialize(validators = [])
      @validators = Array(validators)
    end

    def add_validator(validator)
      @validators << validator
    end

    def run
      ActiveSupport::Notifications.subscribe("factory_bot.compile_factory", &validate_compiled_factory)
    end

    private

    def validate_compiled_factory
      proc do |event|
        @validators.each { |validator| validator.validate!(event.payload) }
      end
    end
  end
end

Version data entries

4 entries across 3 versions & 2 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/factory_bot_rails-6.4.4/lib/factory_bot_rails/factory_validator.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/factory_bot_rails-6.4.4/lib/factory_bot_rails/factory_validator.rb
factory_bot_rails-6.4.4 lib/factory_bot_rails/factory_validator.rb
factory_bot_rails-6.4.3 lib/factory_bot_rails/factory_validator.rb