Validate hash with mixed required attributes
M-Hagras opened this issue · comments
Mohammed Hagras commented
Is there a way to validate nested hash with attributes required and attributes optional ?
params: { a: required, X: { 'Y': required, 'Z': optional }, b: optional }
Something like
required do
string :a
hash :x do
string :y
end
end
optional do
string :b
hash :x do
string :z
end
end
thanks
Eugene Kenny commented
You can use required
and optional
blocks inside a hash filter:
required do
string :a
hash :x do
required do
string :y
end
optional do
string :z
end
end
end
optional do
string :b
end
Mohammed Hagras commented
@eugeneius Thanks 👍