From 04f78ef7a46ae4c4b8ab49153c16983c590783f5 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Fri, 19 Apr 2024 20:51:48 +0100 Subject: First parse of an Excel file --- cmd/dbasik-api/helpers.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'cmd/dbasik-api/helpers.go') diff --git a/cmd/dbasik-api/helpers.go b/cmd/dbasik-api/helpers.go index 3b07dc2..68d9f66 100644 --- a/cmd/dbasik-api/helpers.go +++ b/cmd/dbasik-api/helpers.go @@ -20,9 +20,19 @@ package main import ( "encoding/json" "net/http" + "regexp" ) -// We want this so that our JSON is nested under a key at the top, e.g. "datamap:"... +// validateSpreadsheetCell checks that the cellRef is in a valid format +func validateSpreadsheetCell(cellRef string) bool { + pattern := `^[A-Z]+[1-9][0-9]*$` + + regExp := regexp.MustCompile(pattern) + + return regExp.MatchString(cellRef) +} + +// We want this so that our JSON is nested under a key at the top, e.g. "Datamap:"... type envelope map[string]interface{} // writeJSON)Pretty() helper for sending responses - pretty prints output. This takes the destination http.ResponseWriter, the -- cgit v1.2.3