hey, all..
i was wondering what the current best practice is for handling object validation.. how do we define if an object is valid, and if not, what happens to that object? with my current day job framework, the validity of an item is directly tied to the model. if you try to save an invalid object, it fails. i know we can use magritte for this, but this seems a little heavy weight of a solution for something i need at all times. is there a best practice or anything on how to handle this? thanks! -- ---- peace, sergio photographer, journalist, visionary http://www.ThoseOptimizeGuys.com http://www.CodingForHire.com http://www.coffee-black.com http://www.painlessfrugality.com http://www.twitter.com/sergio_101 http://www.facebook.com/sergio101 _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
The answer depends on why you want to validate. I tend to want to
make validation as late and lazy as possible. For example, have you ever used one of those UI's where, when try to tab off a field and it won't let you because it says "Required" or "Invalid format". That approach is wrong. :) For implementation just use good ol'e exception handling in select places (usually pretty high up). That leaves the vast majority of the code clean and unburdened by exception-handling/validation code. On Mon, Oct 15, 2012 at 9:39 AM, sergio_101 <[hidden email]> wrote: > hey, all.. > > i was wondering what the current best practice is for handling object > validation.. > > how do we define if an object is valid, and if not, what happens to > that object? > > with my current day job framework, the validity of an item is directly > tied to the model. if you try to save an invalid object, it fails. > > i know we can use magritte for this, but this seems a little heavy > weight of a solution for something i need at all times. > > is there a best practice or anything on how to handle this? > > thanks! > > -- > ---- > peace, > sergio > photographer, journalist, visionary > > http://www.ThoseOptimizeGuys.com > http://www.CodingForHire.com > http://www.coffee-black.com > http://www.painlessfrugality.com > http://www.twitter.com/sergio_101 > http://www.facebook.com/sergio101 > _______________________________________________ > seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by sergio_101
The VW validation framework discussed in this paper is MIT licensed but
hasn't yet been ported to Pharo: http://www.caesarsystems.com/resources/caesarsystems/files/Extreme_Validation.pdf The framework is the 'Assessments' package (parcel?) by Andres Valoud. On 10/15/2012 07:39 AM, sergio_101 wrote: > hey, all.. > > i was wondering what the current best practice is for handling object > validation.. > > how do we define if an object is valid, and if not, what happens to > that object? > > with my current day job framework, the validity of an item is directly > tied to the model. if you try to save an invalid object, it fails. > > i know we can use magritte for this, but this seems a little heavy > weight of a solution for something i need at all times. > > is there a best practice or anything on how to handle this? > > thanks! > _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Chris Muller-3
On Mon, Oct 15, 2012 at 9:15 AM, Chris Muller <[hidden email]> wrote:
The answer depends on why you want to validate. I tend to want to I come from the other side, and chose not to use exception handlers for validation, and rather let seaside/smalltalk raise an exception if there is an issue in my model during normal execution. This tells me theres a bug somewhere that needs fixing. I found a nice component in the seaside book used to display messages (StMessageComponent), and built a validation setup around that. I make sure all validation is done from the UI. It just calls #validate: with a msg component as the argument. each class in my model validates itself, and returns true or false, and if false the msg component has the message to display. The UI does not return from the edit/add/delete/whatever until all validation passes. _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Chris Muller-3
> For implementation just use good ol'e exception handling in select
> places (usually pretty high up). That leaves the vast majority of the > code clean and unburdened by exception-handling/validation code. > > i am not sure i follow... do you mean.. have a model throw an exception if validity is not met? -- ---- peace, sergio photographer, journalist, visionary http://www.ThoseOptimizeGuys.com http://www.CodingForHire.com http://www.coffee-black.com http://www.painlessfrugality.com http://www.twitter.com/sergio_101 http://www.facebook.com/sergio101 _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
On Mon, Oct 15, 2012 at 1:29 PM, sergio_101 <[hidden email]> wrote:
>> For implementation just use good ol'e exception handling in select >> places (usually pretty high up). That leaves the vast majority of the >> code clean and unburdened by exception-handling/validation code. > > i am not sure i follow... > > do you mean.. have a model throw an exception if validity is not met? It depends on what you mean by "validity". To me, just saving the object to be worked on later should not present any validation errors. Something can only be "invalid" at the point it is attempted to be *consumed* by the domain for actual processing, but can't be. Until then, no worries about validity should be expressed by the app or the code. That's what I was trying to convey by my example about validating when a field merely loses focus. That field is not needing to be consumed yet, so doing it merely by losing focus is too eager. It should be done only just before it is absolutely needed, for example, when the form is submitted. Exception handling is one way, but sometimes user-entries need to be pre-validated up-front and so a direct approach is fine there too (e.g., #validationErrors could return a collection of problems which, if empty, indicates no errors). _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
> yet, so doing it merely by losing focus is too eager. It should be
> done only just before it is absolutely needed, for example, when the > form is submitted. > ah, yes.. i am thinking that the data would be validated when the form is submitted.. trying to think about how to integrate validation into the model, so no matter where the data comes from (a form, or a sub-form) it will only have one place to find validation rules.. -- ---- peace, sergio photographer, journalist, visionary http://www.ThoseOptimizeGuys.com http://www.CodingForHire.com http://www.coffee-black.com http://www.painlessfrugality.com http://www.twitter.com/sergio_101 http://www.facebook.com/sergio101 _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by sergio_101
In Deltawerken the Validation rules are a domain concern.
Most validators are defined in the class side field definitions. How to apply them is decided when building a ui component. That allows generating javascript for client-side validation as well as server side checks before commit, or while doing bulk-loads. At ESUG I heard about using the unit tests for validation. Sounds like a good idea, and I hope to find some time to try that. Stephan _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Stephan Eggermont <stephan <at> stack.nl> writes:
your pattern is most like the patter used in a Web Framework I implemented for the banking industry in loan processing. In this framework javascript at the client perform validation at submit time or AJAX put time. Domain validations are performed at the client by downloadoing domain validation rules in javascript. In the case that javascript is not enabled at the client, javscript code at the server is used to validate the form fields and to perform domain validation. By the way domain classes mantain domain validation rules and field validation rules in a subset of javascript; the javascript is downloaded for execution at the client when the client has javascript enabled _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Stephan Eggermont-3
Stephan Eggermont <stephan <at> stack.nl> writes:
Could you point us to sample code that performs validation at both the client and the server? _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |