def validatePrice_error_(self, value, error): if value >= 0: return True, value, None errorString = "Price cannot be negative" userInfoDict = {NSLocalizedDescriptionKey: errorString} error = NSError.alloc().initWithDomain_code_userInfo_( ITEM_ERROR_DOMAIN, ITEM_NEGATIVE_PRICE, userInfoDict ) return False, value, error
def validateMaxOffset_error_(self, ioValue, error): if ioValue is None: # trap this in setNilValueForKey # alternative might be to create new NSNumber with value 0 here return True if ioValue <= 0.0: errorString = NSLocalizedStringFromTable( "Maximum Offset must be greater than zero", "Joystick", "validation: zero maxOffset error", ) userInfoDict = {NSLocalizedDescriptionKey: errorString} error = NSError.alloc().initWithDomain_code_userInfo_( "JoystickView", 1, userInfoDict) return False, error return True, None