The Artima Developer Community
Sponsored Link

Python Buzz Forum
Contextual Validation

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ian Bicking

Posts: 900
Nickname: ianb
Registered: Apr, 2003

Ian Bicking is a freelance programmer
Contextual Validation Posted: Dec 15, 2005 5:34 PM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Ian Bicking.
Original Post: Contextual Validation
Feed Title: Ian Bicking
Feed URL: http://www.ianbicking.org/feeds/atom.xml
Feed Description: Thoughts on Python and Programming.
Latest Python Buzz Posts
Latest Python Buzz Posts by Ian Bicking
Latest Posts From Ian Bicking

Advertisement

Martin Fowler just put up a page on Contextual Validation. I don't feel like adding much to that right now, except to say that FormEncode is built around contextual validation. SQLObject uses FormEncode internally, but still just as contextual validation -- the context there being Python-process-to-database. That means it validates that you put ints into INT fields and stuff like that, or handles encoding or other storage transformations. It doesn't (and won't) validate all your business logic. It won't make sure that passwords are no less than 5 characters long. It won't validate that zip codes fit a certain format. None of that. That isn't storage. I'd argue that isn't even a good model.

Instead FormEncode sees validation as a transformation, as data moves from one place to another. From Python to the database. From an HTML form to your internal structures, and so on. So objects only get validation schemas when they embody some transformation (and SQLObject, as an example, embodies one kind of transformation, but just one).

Now, lest you think this is an academic distinction and overdesign, I should emphasize that this makes your models more useful, your data more agile, the risk of strict validation less risky. This isn't about tying everything down, enforcing absolute integrity. Contextual validation means validating less, not more. But if you are data integrity freak (sorry, enthusiast) you might not like this kind of validation.

Anyway, it's nice to see someone give a name to the pattern, and it's nice to have an authority I can point to if asked to justify the decision.

Read: Contextual Validation

Topic: Structured Blogging is official Previous Topic   Next Topic Topic: Ultra-short game reviews

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use