lib/util/params/params.rb in util-params-0.2.11 vs lib/util/params/params.rb in util-params-0.2.13
- old
+ new
@@ -24,40 +24,48 @@
options = options.deep_symbolize_keys
key = options[:key]
val = _load_val params.permit!.to_h, key, options[:default], options[:require]
+ _push_error "*[#{key.to_s}] == nil" unless options[:null]
return nil if val.nil?
_validate key, options[:type], val, options
end
def get_int_params key, options={}
- get_params options.merge(key: key, type: Type::INTEGER)
+ base = {key: key, type: Type::INTEGER, null: true}
+ get_params base.merge(options)
end
def get_str_params key, options={}
- get_params options.merge(key: key, type: Type::STRING)
+ base = {key: key, type: Type::STRING, null: true}
+ get_params base.merge(options)
end
def get_float_params key, options={}
- get_params options.merge(key: key, type: Type::FLOAT)
+ base = {key: key, type: Type::FLOAT, null: true}
+ get_params base.merge(options)
end
def get_file_params key, options={}
- get_params options.merge(key: key, type: Type::FILE)
+ base = {key: key, type: Type::FILE, null: true}
+ get_params base.merge(options)
end
def get_bool_params key, options={}
- get_params options.merge(key: key, type: Type::BOOLEAN)
+ base = {key: key, type: Type::BOOLEAN, null: true}
+ get_params base.merge(options)
end
def get_array_params key, options={}
- get_params options.merge(key: key, type: Type::ARRAY)
+ base = {key: key, type: Type::ARRAY, null: true}
+ get_params base.merge(options)
end
def get_object_params key, options={}
- get_params options.merge(key: key, type: Type::OBJECT)
+ base = {key: key, type: Type::OBJECT, null: true}
+ get_params base.merge(options)
end
# エラーがあるか
def has_params_error?