You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
returns was expected path_parameter parameter to equal <foo>, but was <bar> in body
when path parameter is valid but query string parameters is invalid
fails validation
returns 400 Bad Request
returns parameter <query_parameter> was expected to be present in body
with both parameters valid
succeeds validation
custom validation
for single parameter validation
with only required declaration used
def_single_param_validator:custom_eqldo |expected|
validate{ |actual,name| actual == expected}endparam_validation:my_param,custom_eql('foo')get'/my_path/:my_param'do |my_param|
"validation succeeded for rule: #{custom_eql('foo').description}"end
returns rule description Custom eql in body
with invalid data used
fails validation
returns 404 Not Found
returns parameter my_param was expected to satisfy: Custom eql but was <bar> in body
when used as negated rule
param_validation:my_param_2,custom_eql('foo').negateget'/my_path_2/:my_param_2'do |my_param_2|
"validation succeeded for rule: #{custom_eql('foo').negate.description}"end
returns rule description NOT Custom eql in body
with invalid data used
fails validation
returns 404 Not Found
returns parameter my_param_2 was expected not to satisfy: Custom eql but was <foo> in body
with everything overriden
def_single_param_validator:custom_eql_with_overridesdo |expected|
validatedo |actual,name|
actual == expectedenddescriptiondo"custom description with expected #{expected}"endfailure_messagedo |actual,name|
"custom failure for #{name} with expected #{expected} and actual #{actual}"endfailure_message_when_negateddo |actual,name|
"custom negated failure for #{name} with expected #{expected} and actual #{actual}"endfailure_codedo |parameter_is_in_path|
parameter_is_in_path ? 401 : 409endendparam_validation:my_param,custom_eql_with_overrides('foo')get'/my_path/:my_param'do |my_param|
"validation succeeded for rule: #{custom_eql_with_overrides('foo').description}"end
returns rule description custom description with expected foo in body
with invalid data used
fails validation
returns 401 Our custom defined code
returns custom failure for my_param with expected foo and actual bar in body
when used as negated rule
param_validation:my_param_2,custom_eql_with_overrides('foo').negateget'/my_path_2/:my_param_2'do |my_param_2|
rule=custom_eql_with_overrides('foo').negate"validation succeeded for rule: #{rule.description}"end
returns rule description NOT custom description with expected foo in body
with invalid data used
fails validation
returns 401 Our custom defined code
returns custom negated failure for my_param_2 with expected foo and actual foo in body
for all parameters validation
with only required declaration used
def_all_params_validator:custom_requireddo |expected|
validate{ |params| params.key?expected}endall_params_validationcustom_required('my_param')get'/my_path'do"validation succeeded for rule: #{custom_required('my_param').description}"end
returns rule description Custom required in body
with invalid data used
fails validation
returns 400 Bad Request
returns parameters were expected to satisfy: Custom required but were <{"not_my_param"=>nil}> in body
when used as negated rule
all_params_validationcustom_required('my_param_2').negateget'/my_path_2'dorule=custom_required('my_param_2').negate"validation succeeded for rule: #{rule.description}"end
returns rule description NOT Custom required in body
with invalid data used
fails validation
returns 400 Bad Request
returns parameters were expected not to satisfy: Custom required but were <{"my_param_2"=>nil}> in body
with everything overriden
def_all_params_validator:custom_required_with_overridesdo |expected|
validatedo |params|
params.key?expectedenddescriptiondo"custom description with expected #{expected}"endfailure_messagedo |params|
"custom failure for expected #{expected} and params #{params}"endfailure_message_when_negateddo |params|
"custom negated failure for expected #{expected} and params #{params}"endfailure_codedo |parameter_is_in_path|
parameter_is_in_path ? 401 : 409endendall_params_validationcustom_required_with_overrides('my_param')get'/my_path'dorule=custom_required_with_overrides('my_param')"validation succeeded for rule: #{rule.description}"end
returns rule description custom description with expected my_param in body
with invalid data used
fails validation
returns 409 Our custom defined code
returns custom failure for expected my_param and params {"not_my_param"=>nil} in body
when used as negated rule
all_params_validationcustom_required_with_overrides('my_param_2').negateget'/my_path_2'dorule=custom_required_with_overrides('my_param_2').negate"validation succeeded for rule: #{rule.description}"end
returns rule description NOT custom description with expected my_param_2 in body
with invalid data used
fails validation
returns 409 Our custom defined code
returns custom negated failure for expected my_param_2 and params {"my_param_2"=>nil} in body
with using built-in validation rules inside custom validation rule
def_single_param_validator:with_build_in_eql_todo |expected|
validatedo |actual,name|
check(ValidateMyRoutes::ValidationRules.eql(expected),actual,name)endendparam_validation:my_param,with_build_in_eql_to('foo')get'/my_path/:my_param'do"validation succeeded for rule: #{with_build_in_eql_to('foo').description}"end
returns rule description With build in eql to in body
with valid data passed in
succeeds validation
with invalid data passed in
fails validation
returns 404 Not Found
returns was expected my_param parameter to equal <foo>, but was <bar> in body