class Amber::Validators::Params
- Amber::Validators::Params
- Reference
- Object
Defined in:
amber/validators/params.crConstructors
Instance Method Summary
- 
        #add_rule(rule : BaseRule)
        
          Validates each field with a given set of predicates returns true if the field is valid otherwise returns false 
- #errors : Array(Amber::Validators::Error)
- #params : Hash(String, String?)
- #raw_params : Amber::Router::Params
- #rules : Array(Amber::Validators::BaseRule)
- #to_h : Hash(String, String?)
- #to_unsafe_h
- 
        #valid?
        
          Returns True or false whether the validation passed 
- 
        #validate!
        
          Input must be valid otherwise raises error, if valid returns a hash of validated params Otherwise raises a Validator::ValidationFailed error messages contain errors. 
- 
        #validation(&)
        
          Setups validation rules to be performed 
Macro Summary
- 
        method_missing(call)
        
          This will allow params to respond to HTTP::Params methods. 
Constructor Detail
Instance Method Detail
Validates each field with a given set of predicates returns true if the field is valid otherwise returns false
required(:email) { |p| p.email? & p.size.between? 1..10 }Returns True or false whether the validation passed
unless params.valid?
  response.puts {errors: params.errors}.to_json
  response.status_code 400
endInput must be valid otherwise raises error, if valid returns a hash of validated params Otherwise raises a Validator::ValidationFailed error messages contain errors.
user = User.new params.validate!Setups validation rules to be performed
params.validation do
  required(:email) { |p| p.url? }
  required(:age, UInt32)
endMacro Detail
This will allow params to respond to HTTP::Params methods. For example: [], []?, add, delete, each, fetch, etc.