Implemented By:
EOEnterpriseObject
EOCustomObject
EOGenericRecord
Package:
com.apple.client.eocontrol (Java Client)
com.apple.yellow.eocontrol (WebObjects and Yellow Box)
Inherits From:
java.lang.Object
Package:
com.apple.client.eocontrol
The EOValidation interface defines the way that enterprise objects validate their values. The validation methods check for illegal value types, values outside of established limits, illegal relationships, and so on. EOCustomObject and EOGenericRecord provide default implementations of EOValidation, which are described in detail in this specification.
There are two kinds of validation methods. The first validates individual properties, and the second validates an entire object to see if it's ready for a specific operation (inserting, updating, and deleting). The two different types are discussed in more detail in the sections "Validating Individual Properties" and "Validating Before an Operation."
validateForDelete
public abstract void validateForDelete () throws EOValidation.Exception
Confirms that the receiver can be deleted in its current state, throwing an EOValidation.Exception if it can't. For example, an object can't be deleted if it has a relationship with a delete rule of EOClassDescription.DeleteRuleDeny and that relationship has a destination object.
EOCustomObject's implementation sends the receiver's EOClassDescription a message (which performs basic checking based on the presence or absence of values). Subclasses should invoke super 's implementation before performing their own validation, and should combine any exception thrown by super 's implementation with their own.
See also: - propagateDeleteWithEditingContext (EOEnterpriseObject), "Constructors" (EOValidationException)
validateForInsert
public abstract void validateForInsert () throws EOValidation.Exception
Confirms that the receiver can be inserted in its current state, throwing an EOValidation.Exception if it can't. EOCustomObject's implementation simply invokes validateForSave .
The method validateForSave is the generic validation method for when an object is written to the external store. If an object performs validation that isn't specific to insertion, it should go in validateForSave .
validateForSave
public abstract void validateForSave ()
Confirms that the receiver can be saved in its current state, throwing an EOValidation.Exception if it can't. EOCustomObject's implementation sends the receiver's EOClassDescription a validateObjectForSave message, then iterates through all of the receiver's properties, invoking validateValueForKey for each one. If this results in more than one exception, the exception returned contains the additional ones in its userInfo dictionary under the EOValidation.Exception.AdditionalExceptions key. Subclasses should invoke super 's implementation before performing their own validation, and should combine any exception thrown by super 's implementation with their own.
Enterprise objects can implement this method to check that certain relations between properties hold; for example, that the end date of a vacation period follows the begin date. To validate an individual property, you can simply implement a method for it as described under validateValueForKey .
See also: "Constructors" (EOValidationException)
validateForUpdate
public abstract void validateForUpdate () throws EOValidation.Exception
Confirms that the receiver can be inserted in its current state, throwing an EOValidation.Exception if it can't. EOCustomObject's implementation simply invokes validateForSave .
The method validateForSave is the generic validation method for when an object is written to the external store. If an object performs validation that isn't specific to updating, it should go in validateForSave .
validateValueForKey
public abstract java.lang.Object validateValueForKey (
java.lang.Object value,
java.lang.String key) throws EOValidation.Exception
Confirms that value is legal for the receiver's property named by key. Throws an EOValidation.Exception if it can't confirm that the value is legal. The implementation can provide a coerced value by returning the value. This lets you convert strings to dates or numbers or maybe convert strings to an enumerated type value. EOCustomObject's implementation sends a validateValueForKey message to the receiver's EOClassDescription.
Enterprise objects can implement individual validate Key methods to check limits, test for nonsense values, and otherwise confirm individual properties. To validate multiple properties based on relations among them, override the appropriate validateFor... method.
"Constructors" (EOValidationException)