Results 1 to 2 of 2

Thread: Data access in Validator?

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Posts
    19

    Default Data access in Validator?

    Any opinions on the best place to locate complex validation and/or validation that requires database access, for example validating a username and password?

    I see two options, and I could obviously be missing several:

    1.) A LoginCommand object backing the login form is associated with a LoginCommandValidator object which checks to see whether or not a username and password were supplied AND makes the call (I'm sure through some persistence object) to the database to verify the username and password

    or

    2.) The LoginCommandValidator from above simply verifies that a username and password were supplied. Validation of the username and password against the database occur in the LoginController's onBindAndValidator method (is this the right place to put it in this scenario?).

    Kind of along these lines, how robust should these Validator objects be? For example, if I have an OrderValidator there may be (relatively) extremely complex business logic and/or database access/lookups involved in validating an order. Is the OrderValidator the place for this?

    Any strong thoughts one way or the other? Thanks in advance.

    Brian

  2. #2
    Join Date
    Aug 2004
    Posts
    25

    Default

    I don't put anything other than basic sanity checking in a validator. Anything that would classify as business logic goes in a class that's called by the method that processes the form (like onSubmit) in the controller.

Similar Threads

  1. Replies: 2
    Last Post: Jul 21st, 2005, 06:09 PM
  2. Replies: 2
    Last Post: Apr 29th, 2005, 02:17 AM
  3. Replies: 2
    Last Post: Nov 1st, 2004, 01:43 PM
  4. Replies: 1
    Last Post: Oct 20th, 2004, 05:40 AM
  5. Replies: 5
    Last Post: Sep 8th, 2004, 08:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •