Ticket #1081 (closed defect: fixed)

Opened 13 months ago

Last modified 10 months ago

preValidate() and postValidate() record hooks don't exist

Reported by: adamthehutt Owned by: adamthehutt
Priority: minor Milestone:
Component: Record Version: 1.0.0
Severity: Keywords:
Cc: Has Test: no
Status: Pending Core Response Has Patch: no

Description

The documentation suggests that preValidate() and postValidate() should be usable as record hooks, but they don't exist in the code. preValidate() is especially useful for cleaning up data before sending to the database.

Attachments

validation_hooks_patch.txt (4.1 KB) - added by adamthehutt 13 months ago.
Patch against 0.10 branch

Change History

Changed 13 months ago by adamthehutt

Patch against 0.10 branch

follow-up: ↓ 2   Changed 13 months ago by jwage

  • milestone changed from 0.11.3 to 0.12.0

The manual does document these methods, but they don't exist. However, your goal can be accomplished by using the validate(), validateOnUpdate() or validateOnInsert() methods. I don't see how a post validation hook could ever be useful. If you know of a use case please let us know.

in reply to: ↑ 1   Changed 13 months ago by adamthehutt

Replying to jwage:

The manual does document these methods, but they don't exist. However, your goal can be accomplished by using the validate(), validateOnUpdate() or validateOnInsert() methods. I don't see how a post validation hook could ever be useful. If you know of a use case please let us know.

jwage -

Yes, you can accomplish the same thing using validate(), but that smells wrong to me. The validate() method should be strictly about checking for data validity. preValidate() is useful for cleaning up user data BEFORE checking if it's valid (which I need to do constantly). Maybe I'm being anal, but that's my take on it.

I don't have a use case for postValidate(), although IMHO it should exist for the sake of symmetry and consistency.

  Changed 10 months ago by jwage

  • has_patch unset
  • version changed from 0.11 to 1.0
  • mystatus set to Pending Core Response
  • milestone changed from Unknown to 1.0.0-RC2
  • has_test unset

  Changed 10 months ago by jwage

  • status changed from new to closed
  • resolution set to fixed

(In [4865]) fixes #1081 - Added pre/postValidate() support

  Changed 10 months ago by anonymous

  • milestone New deleted

Milestone New deleted

Note: See TracTickets for help on using tickets.