         idWithPrefix = "#{@_keyPrefix}#{id}"
 
         afterValidate = (error = null) =>
-            return callback(error) if error
+            return callback(error) if error?
 
             if match and @_validate?
                 matched = @_validator.match data


        idWithPrefix = "#{@_keyPrefix}#{id}"
        @_dataSource.bucket.remove idWithPrefix, options, (error, result) ->
            return callback error if error
            return callback null, result

    # Inserts a single record using the primary key, it updates if the key already exists

                @_addCreatedAt data

                @_dataSource.bucket.insert newId, data, options, (error, result) ->
                    return callback error if error?
                    return callback null, result

            if validate and @_validate?
