-
Notifications
You must be signed in to change notification settings - Fork 25
Refactor validation #171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Refactor validation #171
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
aa9fbd9
refactor validateSettings and tests
jwildfire d6d9a9c
ignoring vectors for now. #170 filed.
jwildfire a3e3fdc
clear checks & fix #164
jwildfire c798e6a
more validation tweaks. #172
jwildfire bdaf517
fix #172
jwildfire 14313e8
update description
jwildfire f79b94d
Merge branch 'dev-v0.8.0' into refactor-validation
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #' Check that a setting parameter has a matching data field | ||
| #' | ||
| #' Checks that a single parameter from the settings list matches a field value in a specified data set | ||
| #' | ||
| #' This function compares settings with field values as part of the \code{validateSettings()} function. More specifically, the function checks whether the \code{fieldKey} in a \code{settings} object matches a column/field combination in \code{"data"}. The function makes 2 major assumptions about the structure of the settings object. First, it assumes that the first value in fieldKey is "settingName_values" and there is a corresponding "settingName_col" setting that defines the column to search for field-level data. Second, it expects that the value specified by key/settings is a list, and that each value in the list is a field of the variable above. | ||
| #' | ||
| #' @param fieldKey a list (like those provided by \code{getSettingKeys())} defining the position of parameter in the settings object. | ||
| #' @param settings The settings list used to generate a chart like \code{eDISH()} | ||
| #' @param data A data frame to check for the specified field | ||
| #' @return A list containing the results of the check following the format specified in \code{validateSettings()[["checkList"]]} | ||
| #' | ||
| #' | ||
| #' @examples | ||
| #' testSettings<-generateSettings(standard="AdAM") | ||
| #' fields<-list("measure_values","TB") | ||
| #' safetyGraphics:::checkFieldSettings(fieldKey=fields,settings=testSettings, data=adlbc) | ||
| #' | ||
| #' @keywords internal | ||
|
|
||
| checkFieldSettings <- function(fieldKey, settings, data){ | ||
| stopifnot(typeof(fieldKey)=="list", typeof(settings)=="list") | ||
|
|
||
| # Check to see that the field data specified in the seetings is found in the data | ||
| fieldCheck <- list() | ||
| fieldCheck$key<-fieldKey | ||
| fieldCheck$text_key<- paste( unlist(fieldKey), collapse='--') | ||
| fieldCheck$type <- "field value from setting found in data" | ||
| fieldCheck$description <- "field value from setting found in data" | ||
| fieldCheck$value <- getSettingValue(key=fieldCheck$key,settings=settings) | ||
|
|
||
| #get the name of the column containing the field | ||
| columnTextKey<-getSettingsMetadata(cols="field_column_key",text_keys=fieldCheck$text_key) | ||
| columnKey<-textKeysToList(columnTextKey)[[1]] | ||
| columnName<-getSettingValue(key=columnKey,settings=settings) | ||
|
|
||
| if(length(fieldCheck$value)>0){ | ||
| fieldCheck$valid <- hasField(fieldValue=fieldCheck$value, columnName=columnName,data=data) | ||
| }else{ | ||
| fieldCheck$value <- "--No Value Given--" | ||
| fieldCheck$valid <- TRUE #null values are ok | ||
| } | ||
| fieldCheck$message <- ifelse(!fieldCheck$valid, paste0("Value of ",fieldCheck$value, " for '",fieldCheck$text_key,"' not found in ",columnName),"") | ||
|
|
||
| return(fieldCheck) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may need to adjust dependencies