Open laceysanderson opened 2 months ago
/**
* input_types: {"file"}
*/
class validateFile {
public function validateFileObject($filename, $fid = NULL) {
// Parameter check:
Check $filename is a valid path and is accessible (when provided).
Throw an exception if invalid file path.
Check $fid is 0 or not integer value (when provided).
Throw an exception if non-integer value.
// Has File ID and Id can be loaded check
// Load $filename (load by uri) or $fid (load by file id)
Failed if it cannot load the file. File has no file id assigned/created.
// File exists check.
// Reference file uri and check if it exists in the filesystem.
// ie: file_exists($file->uri);
Failed if the file does not exists.
// MIME and file extension check.
// Get the file mime type provided by the Drupal File System object.
// ie: $file->getMimeType();
Failed if type/extension is not the expected mime type configured.
// File is not empty check.
// Get the file size provided by the Drupal File System object.
// ie: filesize($file->uri);
Failed if file size is 0
}
}
/**
* input_types: {"header"}
*/
class validTsvFile {
public function validateRow($header_row)
// It will implement validateRow and check that the contents of the first row are in TSV format.
}
}
Unsure what to do here 😟
Branch
g4.88-fileValidators
Groups
Group 2 - Data Importing, Group 4 - API | Services | Plugins
Dependencies
92
93
Describe
This issue is meant to upgrade the existing DataFile to the new style described in Issue https://github.com/TripalCultivate/TripalCultivate-Phenotypes/issues/82.
Does not remove the original validator! Does not update trait importer to use this new validator.
Design
This should be split into two validators.
The first one is a generic check the file is valid without looking it in. This will be in inputType file and be given the filename with full path and the fid (if uploaded). It will check the following:
The other one is specific to tsv format and has an inputType of header and will be given the first row of the file as an array. It will implement validateRow and check that the contents of the first row are in TSV format.