Skip to content

Commit

Permalink
Allow + in FRM names (#408)
Browse files Browse the repository at this point in the history
* Add error logging for validation failures.

* Add another valid test case for client state

* Allow + in frm name
  • Loading branch information
dgarciabriseno authored Jul 29, 2024
1 parent 72fc25b commit 1d8a600
Show file tree
Hide file tree
Showing 3 changed files with 264 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docroot/schema/event_layers.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"type": "array",
"items": {
"type": "string",
"pattern": "^[\\\\()a-zA-Z0-9_-]+$",
"pattern": "^[\\\\()a-zA-Z0-9_+-]+$",
"minLength": 1,
"maxLength": 60
}
Expand Down
4 changes: 4 additions & 0 deletions src/Validation/InputValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,10 @@ public static function checkJsonSchema(array $json_fields, array &$params) {

if (!$result->isValid()) {
$error = (new ErrorFormatter())->format($result->error());
$exc = new InvalidArgumentException("Invalid JSON: " . print_r($error, true) . "\n\n" . print_r($data, true));
// Log the error to disk so we can debug later
include_once HV_ROOT_DIR.'/../src/Helper/ErrorHandler.php';
logException($exc, "SchemaValidation_");
throw new InvalidArgumentException("Invalid JSON: " . print_r($error, true));
}
}
Expand Down
259 changes: 259 additions & 0 deletions tests/unit_tests/validation/test_data/client_state/valid/valid_17.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
{
"date": 1410269529000,
"imageScale": 4.84088176,
"centerX": -2894.0322215830834,
"centerY": 101.72638697583727,
"imageLayers": [
{
"end": "2024-07-29 17:33:45",
"start": "2010-06-02 00:05:36",
"opacity": 100,
"visible": true,
"diffTime": 1,
"nickname": "AIA 171",
"sourceId": 10,
"uiLabels": [
{
"label": "Observatory",
"name": "SDO"
},
{
"label": "Instrument",
"name": "AIA"
},
{
"label": "Measurement",
"name": "171"
}
],
"diffCount": 60,
"Instrument": "AIA",
"difference": 0,
"Measurement": "171",
"Observatory": "SDO",
"baseDiffTime": "2024-07-19T13:28:50.000Z",
"layeringOrder": 1
}
],
"eventLayers": {
"tree_HEK": {
"id": "HEK",
"layers": [
{
"event_type": "AR",
"frms": [
"HMI_SHARP",
"NOAA_SWPC_Observer",
"SPoCA"
],
"event_instances": [],
"open": 1
},
{
"event_type": "CC",
"frms": [
"all"
],
"event_instances": [],
"open": 1
},
{
"event_type": "CD",
"frms": [
"all"
],
"event_instances": [],
"open": 1
},
{
"event_type": "CH",
"frms": [
"SPoCA"
],
"event_instances": [],
"open": 1
},
{
"event_type": "CJ",
"frms": [
"all"
],
"event_instances": [],
"open": 1
},
{
"event_type": "CE",
"frms": [
"all"
],
"event_instances": [],
"open": 1
},
{
"event_type": "CR",
"frms": [
"all"
],
"event_instances": [],
"open": 1
},
{
"event_type": "CW",
"frms": [
"all"
],
"event_instances": [],
"open": 1
},
{
"event_type": "EF",
"frms": [
"Emerging_flux_region_module"
],
"event_instances": [],
"open": 1
},
{
"event_type": "ER",
"frms": [
"all"
],
"event_instances": [],
"open": 1
},
{
"event_type": "FI",
"frms": [
"all"
],
"event_instances": [],
"open": 1
},
{
"event_type": "FA",
"frms": [
"all"
],
"event_instances": [],
"open": 1
},
{
"event_type": "FE",
"frms": [
"all"
],
"event_instances": [],
"open": 1
},
{
"event_type": "FL",
"frms": [
"all"
],
"event_instances": [],
"open": 1
},
{
"event_type": "LP",
"frms": [
"all"
],
"event_instances": [],
"open": 1
},
{
"event_type": "OS",
"frms": [
"all"
],
"event_instances": [],
"open": 1
},
{
"event_type": "PG",
"frms": [
"all"
],
"event_instances": [],
"open": 1
},
{
"event_type": "SG",
"frms": [
"Sigmoid_Sniffer"
],
"event_instances": [],
"open": 1
},
{
"event_type": "SP",
"frms": [
"all"
],
"event_instances": [],
"open": 1
},
{
"event_type": "SS",
"frms": [
"EGSO_SFC"
],
"event_instances": [],
"open": 1
},
{
"event_type": "TO",
"frms": [
"SSW_PFSS_v2_\\+_null_point_finder_v20180808"
],
"event_instances": [],
"open": 1
}
],
"visible": true,
"labels_visible": true,
"markers_visible": true,
"layer_available_visible": true
},
"tree_CCMC": {
"id": "CCMC",
"layers": [
{
"event_type": "C3",
"frms": [
"CME"
],
"event_instances": [],
"open": 1
},
{
"event_type": "FP",
"frms": [
"MAG4_LoS_FEr"
],
"event_instances": [],
"open": 1
}
],
"visible": true,
"labels_visible": true,
"markers_visible": true,
"layer_available_visible": true
},
"tree_RHESSI": {
"id": "RHESSI",
"layers": [],
"visible": true,
"labels_visible": true,
"markers_visible": true,
"layer_available_visible": true
}
},
"celestialBodies": {
"soho": [],
"stereo_a": [
"stereo_a-mercury-tree-label"
],
"stereo_b": []
}
}

0 comments on commit 1d8a600

Please sign in to comment.