triggerrangevalidation <- function(tup) { # compute the list of extrema extrema <- eval(parse(text=tup[["args"]][1])) # Now get the list of values in the tuple that triggered # the event. vals <- tupleValues(tup$tuple) # Compute if any of the values are outside of the range specified # in extrema. Each value and range is indexed by the name of the field. if(!all(sapply(names(vals), function(i, vals, extrema) { # check to see if there is a range specified for this variable # If not, we accept any value. if(is.null(extrema[[i]])) ans <- TRUE else { # So there is a range. Now check whether the value is # within that range. ans <- vals[[i]] > extrema[[i]][2] & vals[[i]] < extrema[[i]][1] } # If the value is outside the range, report this. # This works for all variables rather than giving just a # a single reject without explaining which fields caused # the problem. if(ans == FALSE) { msg <- paste("Rejecting element",i, vals[[i]], "[", extrema[[i]][1], ",",extrema[[i]][2], "]") print(msg) } ans }, vals, extrema))) { tup$tuple <- NULL } return(tup$tuple) }