ships.Function.validateLoadout - Elite-Dangerous-Almanac/Almanac-Core GitHub Wiki
@elite-dangerous-almanac/core / ships / validateLoadout
validateLoadout(
input):LoadoutValidation
Defined in: src/ships/loadout-validation.ts:308
Validate a resolved fitted build without importing any catalogue.
Hull layout and resolved module classifications, and optionally what the assembled ship weighs.
Structural validity, operational completeness, and diagnostics.
Every rule but one reads the structure alone. The exception is
thrusterMassExceeded: state LoadoutValidationInput.mass and the fitted
thrusters' ValidationModule.thrusterMaxMass, and a ship too heavy for its own
thrusters is reported, because above that rating the thruster curve contributes
nothing and the ship does not move at all.
The rating is weighed against each ThrusterLoad the input can state, and the lightest load that is already too heavy is the one reported. Every such finding is an error, so it clears both LoadoutValidation.valid and LoadoutValidation.complete: the game refuses a fit whose thrusters are rated below any load the ship can reach, a full hold included.
import { validateLoadout } from '@elite-dangerous-almanac/core/ships/loadout-validation';
const result = validateLoadout({ shipSymbol: 'CustomHull', slots: [], modules: [] });
result.valid; // -> true: no impossible fit was claimed
result.complete; // -> true: the supplied layout has no required mounts
const overloaded = validateLoadout({
shipSymbol: 'CustomHull',
slots: [],
mass: { dry: 60.6, fuel: 25 },
modules: [
{
slot: 'MainEngines',
symbol: 'Int_Engine_Size2_Class1',
requiresKnownSlot: false,
fitError: null,
thrusterMaxMass: 72,
},
],
});
overloaded.valid; // -> false
overloaded.issues[0]?.code; // -> 'thrusterMassExceeded'
overloaded.issues[0]?.params?.load; // -> 'unladen': it is the full tank that sinks itIf input.slots is not an array.
If a figure in input.mass, or a module's thrusterMaxMass, is
present and is not a finite number of zero or more.