Class: ArgsParser::Validator

### Home Classes Methods

### In Files

- lib/args_parser/validator.rb

### Parent

Object

### Methods

- ::new
- #add
- #validate

### Class/Module Index

Quicksearch

- ArgsParser
- ArgsParser::Config
- ArgsParser::Filter
- ArgsParser::Parser
- ArgsParser::ValidationError
- ArgsParser::Validator

No matching classes.

# ArgsParser::Validator

### Attributes

validators[R]

### Public Class Methods

new() click to toggle source

    # File lib/args_parser/validator.rb, line 6
    def initialize
      @validators = []
    end

### Public Instance Methods

add(name, message, validator) click to toggle source

    # File lib/args_parser/validator.rb, line 10
    def add(name, message, validator)
      name = name.to_sym if name
      validators.push({:name => name, :message => message, :validator => validator})
    end

validate(name, value) click to toggle source

    # File lib/args_parser/validator.rb, line 15
    def validate(name, value)
      validators.each do |f|
        if !f[:name] or f[:name] == name
          return f[:message] unless f[:validator].call(value)
        end
      end
      nil
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.