Validate call sign before sending to modem.

This commit is contained in:
Mashintime 2024-01-13 13:08:12 -05:00
parent 1c4402094a
commit f67f62f3ad
2 changed files with 17 additions and 4 deletions

View file

@ -1,5 +1,17 @@
<script setup lang="ts">
import { settingsStore as settings, onChange } from "../store/settingsStore.js";
import { settingsStore as settings, onChange, getRemote } from "../store/settingsStore.js";
import {validateCallsignWithSSID, validateCallsignWithoutSSID} from "../js/freedata";
function validateCall()
{
if (validateCallsignWithoutSSID(settings.remote.STATION.mycall))
//Send new callsign to modem if valid
onChange();
else
//Reload settings from modem as invalid callsign was passed in
getRemote();
}
</script>
<template>
<!-- station callsign -->
@ -14,8 +26,9 @@ import { settingsStore as settings, onChange } from "../store/settingsStore.js";
id="myCall"
aria-label="Station Callsign"
aria-describedby="basic-addon1"
@change="onChange"
v-model="settings.remote.STATION.mycall"
@change="validateCall"
/>
</div>

View file

@ -61,7 +61,7 @@ export function sortByPropertyDesc(property) {
* @returns true or false if callsign appears to be valid with an SSID
*/
export function validateCallsignWithSSID(callsign: string) {
var patt = new RegExp("^[A-Z,a-z]+[0-9][A-Z,a-z]*-(1[0-5]|[0-9])$");
var patt = new RegExp("^[A-Z]+[0-9][A-Z]*-(1[0-5]|[0-9])$");
if (
callsign === undefined ||
@ -82,7 +82,7 @@ export function validateCallsignWithSSID(callsign: string) {
* @returns true or false if callsign appears to be valid without an SSID
*/
export function validateCallsignWithoutSSID(callsign: string) {
var patt = new RegExp("^[A-Za-z]+[0-9][A-Za-z]+$");
var patt = new RegExp("^[A-Z]+[0-9][A-Z]+$");
if (
callsign === undefined ||