Skip to contents

The validate_specimens function serves as a main driver for validating specimens data, both for Micronix and Cryovial specimens. The process involves several key steps:

Usage

validate_specimens(
  user_data,
  sample_type,
  user_action,
  file_type,
  database = Sys.getenv("SDB_PATH")
)

Arguments

user_data

Character string. The path to the user-provided CSV file to be validated.

sample_type

Character string. The type of sample being validated. Expected values are "micronix" or "cryovial".

user_action

Character string. The action being performed by the user, e.g. "upload".

database

Character string. The database connection or specification for validation. Default is the system environment variable "SDB_PATH".

Value

A data frame. The validated and potentially modified user data if validation passes. If validation does not pass, an error will be raised.

Details

  1. Formatting the provided user CSV based on the sample type and action with format_user_csv.

  2. Validation based on the sample type using either validate_micronix or validate_cryovial.

  3. If the user action is "upload", dates in the data will be further validated using validate_dates_with_tokens.

  4. Any errors during the validation steps are accumulated and, if present, will trigger an error message, stopping the process.

  5. If unknown date tokens are found during validation, these are handled using the handle_unknown_date_tokens function.

At the end of the validation process, the user data will be either ready for upload to the database or returned to the user with errors.