mathieujobin on rails7
update framework files in dummy… (compare)
mathieujobin on rails7
run tests against rails 7.0 update framework files in dummy… (compare)
mathieujobin on v0.7.2
mathieujobin on master
Release 0.7.2 - Update Changelog (compare)
@buren Nice thanks. That customized validation sounds interesting, going to look for it, any advice.
I've noticed that in production an error returns a JSON that says that something has gone wrong, but in development it describes the parameter that i am missing. I'd like the response to be a JSON describing the missing attributes
Ok, that was basically what I needed too, though I was also conforming to jsonapi.org so I had to have the response in a certain way.
To me it seemed clear that it would be best to “own” as much of the validation logic as possible.
Are all of the fields required in order to successfully save your model object? (ActiveRecord
or something else..)
If you can/should add those validations directly on the model and then you can return those error in whatever format you want
for ActiveRecord
it could look something like this:
activerecord_model_instance.errors.messages.flat_map do |attribute, errors|
errors.map do |error_message|
{
attribute: attribute,
message: error_message
}
end
end
@damuz91 hm.. well this being Ruby you can basically do whatever you want, its just a matter of how “risky”/“reckless” one can be ;) I haven’t used that parts, so can’t say that I’m particular familiar with it either but here is the code:
Validation code:
https://github.com/Apipie/apipie-rails/blob/296c097f9acb951149d3a67db69b84eb216bdd7e/lib/apipie/dsl_definition.rb#L219-L254
Error classes:
https://github.com/Apipie/apipie-rails/blob/296c097f9acb951149d3a67db69b84eb216bdd7e/lib/apipie/errors.rb
uninitialized constant MyEngine::Apipie