[katello-devel] Apipie and validation.

Ivan Necas inecas at redhat.com
Mon Dec 3 13:44:03 UTC 2012



----- Original Message -----
> 
> 
> ----- Original Message -----
> | On 30/11/12 03:41 PM, Lukas Zapletal wrote:
> | > On Fri, Nov 30, 2012 at 03:02:15PM +0000, Dmitri Dolguikh wrote:
> | >> Repeat after me: validation logic belongs in the model.
> | > Only in an ideal world, Dmitri. ;-)
> | >
> | > Not all our controllers follows REST pattern, and you know that.
> | >
> | This has nothing to do with rest - just common sense. If you start
> | doing
> | validations in controllers, you will inevitable start moving
> | business
> | logic to them.
> | 
> | In our case, instead of perpetuating the problem, let's fix it
> | instead.
> | Step #1 - let's get rid of controller validations.
> | 
> 
> The good thing about the validations is that you can pass them along,
> for example to a client, so it does not need to make the round trip
> to figure out he needs another param.
> 
> I agree that I would prefer the model to raise the error, so should
> probably turn it off by default?

+1 for turning it off by default, for this reason.

However, I wouldn't recommend to getting rid of them completely. Being
able to describe the params with the code has much more value in it than
just with plain strings/comments. This was the original intention of the
apipie gem. We can just run it with validations turned on when we want to
find inconsistencies between documentation and actual code, perhaps automatically
with some test suite for that.

-- Ivan

> 
> I would also look at
> https://github.com/bcardarella/client_side_validations for
> inspirations of how to get the model validations.
> 
> Ohad
> | 
> | _______________________________________________
> | katello-devel mailing list
> | katello-devel at redhat.com
> | https://www.redhat.com/mailman/listinfo/katello-devel
> | 
> 
> _______________________________________________
> katello-devel mailing list
> katello-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/katello-devel
> 




More information about the katello-devel mailing list