Skip to content

ui/map/aircraft/aircraftCreationValidation

Type Aliases

NumericFieldResult

type NumericFieldResult = 
  | {
  ok: true;
  value: number;
}
  | {
  ok: false;
  message: string;
};

Defined in: ui/map/aircraft/aircraftCreationValidation.ts:6

Strict numeric parsing for the Create Aircraft modal fields, extracted from AircraftCreationForm so it can be unit-tested without a DOM.

Functions

parseNumericField()

function parseNumericField(
   raw, 
   label, 
   range?
): NumericFieldResult;

Defined in: ui/map/aircraft/aircraftCreationValidation.ts:21

Parse a numeric form field strictly, with an optional inclusive range.

Uses Number() rather than parseFloat so trailing garbage ("10k", "52.3N") is rejected instead of silently truncated to its numeric prefix, and non-finite results are rejected outright. The old parseFloat + range-check code let NaN through (every comparison with NaN is false), so any non-numeric value reaching these fields went out as CRE ...,NaN,... — which BlueSky accepts (Python's float("nan") parses) and turns into a broken aircraft.

Parameters

raw

string

label

string

range?
min

number

max

number

Returns

NumericFieldResult