File:  [NeXTSTEP 3.3 examples] / Examples / EnterpriseObjects / Validation / Validation.subproj / ValidatingDelegate.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:48:57 2018 UTC (8 years, 1 month ago) by root
Branches: NeXT, MAIN
CVS tags: NeXTSTEP33, HEAD
Sample Programs from NeXSTEP 3.3

#import <eointerface/eointerface.h>

@interface ValidatingDelegate : Object
{
    BOOL validatesImmediately;   // validate when change is made, or only when they 
                                 // try to save?
}

- (void)setValidatesImmediately:(BOOL)yn;
- (BOOL)validatesImmediately;
    // retuns whether the delegate will perform validation checks on user changes
    // on a per-field basis.  If not, check are performed before insert/update/delete.

- (NSDictionary *)controller:(EOController *)controller willSaveEdits: (NSDictionary *)edits toObject:object;
    // to perform validation on changes to objects as they are made.

- (EODataSourceOperationDelegateResponse)controller:(EOController *)controller
    willInsertObject:object
    inDataSource:dataSource;
    // Used to ask object if it's ready to be inserted.
    // By default we will try to validate all of its properties.

- (EODataSourceOperationDelegateResponse)controller:(EOController *)controller
    willUpdateObject:object
    inDataSource:dataSource;
    // Used to ask object if it's ready to be updated.
    // By default we will try to validate all of its properties.

- (EODataSourceOperationDelegateResponse)controller:(EOController *)controller
    willDeleteObject:object
    inDataSource:dataSource;
    // to ask object if it can be deleted.

- (void)reportValidationErrors:(NSDictionary *)errors forObject:object
                  inController:(EOController *)controller;
    // Called by delegate to report validate error.  Default implementation displays
    // a panel.  Subclassers may want to update a status line in the window, or
    // just beep.
@end


@interface NSObject (ValidationProtocols)
// An EO can implement some or all of these methods to play a roll in its validation
- (NSArray *)keysToValidate;
    // Return list of property names that must be valid before object can be
    // inserted or updated.  Default implementation returns an empty array.
    // Better implementations might scan the runtime information in the
    // receiver for methods of the form validateXXXX:.
    // For EOs that keep a pointer to their entity (provided in
    // initWithPrimaryKey:entity) this method could return the classPropertyNames.

- (NSDictionary *)validForDataSource:(id <EODataSources>)dataSource;
    // should return nil if object is valid for insert and update,
    // or a dictionary of key/error message pair describing the problem if not.
    // The default implementation returns
    // [self validateValuesInDictionary:[self valuesForKeys:[self keysToValidate]]]
- (NSDictionary *)validForInsertInDataSource:(id <EODataSources>)dataSource;
    // should return nil if object is valid for insert, or a dictionary of key/error message
    // pair describing the problem if not.  The default implementation calls
    // [self validForDataSource:dataSource]

- (NSDictionary *)validForUpdateInDataSource:(id <EODataSources>)dataSource;
    // should return nil if object is valid for update, or a dictionary of key/error message
    // pair describing the problem if not.  The default implementation calls
    // [self validForDataSource:dataSource]

- (NSDictionary *)validForDeleteInDataSource:(id <EODataSources>)dataSource;
    // should return nil if object is valid for insert, or a dictionary of key/error message
    // pair describing the problem if not.  The default implementation returns nil.
@end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.