Andrea,
Yes, that's totally possible, and in fact, this is how it is designed. I am not sure how you have set it up to get the behavior you're describing.
I created a very basic example from an empty generated app.
Here's the design:
module Endpoints
class Tests
include Praxis::ResourceDefinition
action :update do
description 'Update'
routing { patch '/:id' }
params { attribute :id, Integer }
payload do
attribute :name, String, regexp: /[0-9]+/
attribute :phone, String
end
response :no_content
end
end
end
Here's the Controller:
module Controllers
class Tests
include Praxis::Controller
implements Endpoints::Tests
def update(id:)
puts "Updating #{id} with payload: #{request.payload.dump}"
Praxis::Responses::NoContent.new
end
end
end
And here's the behavior:
passing an invalid regex fails:
HTTP/1.1 400 Bad Request
Content-Type: application/json
Transfer-Encoding: chunked
Server: WEBrick/1.3.1 (Ruby/2.4.3/2017-12-14)
Date: Fri, 05 Oct 2018 06:02:52 GMT
Connection: Keep-Alive
{
"name": "ValidationError",
"summary": "Errors validating payload data",
"errors": [
"$.
payload.name value (bad) does not match regexp (/[0-9]+/)"
]
}
passing a good one succeeds:
HTTP/1.1 204 No Content
Server: WEBrick/1.3.1 (Ruby/2.4.3/2017-12-14)
Date: Fri, 05 Oct 2018 06:03:47 GMT
Connection: Keep-Alive
not passing the attribute at all succeeds (same as passing it with null value):
HTTP/1.1 204 No Content
Server: WEBrick/1.3.1 (Ruby/2.4.3/2017-12-14)
Date: Fri, 05 Oct 2018 06:04:07 GMT
Connection: Keep-Alive
...can you see what the differences in your code are as to find out what it is behaving different than this?
Cheers,
Josep M.