Skip to content

API ReferenceValidationFunction

validateUserProvidedLOCConfig()

function validateUserProvidedLOCConfig(locConfig): Promise<LOCConfigValidationResult>;

Checks a LOCConfig for shape errors before it is handed to the SDK: every configured address and allowlist entry must be a valid Ethereum address, a hardcoded expiration must be in the future, disableLOCExtension / destinationAddressReadOnly must be booleans, and a fixed redeemLiquidation must have a valid liquidator address (with no orphaned liquidatorParams), while resolver functions and null are accepted for deferred or explicit self-liquidation selection, and raw component defaults must match their published shapes. Resolver functions are validated when their transaction-ready context is available. Resolves to undefined when the config is valid; otherwise to one LOCConfigValidationError per problem, addressable by getErrorsByFieldPath. Use validateConfigAndThrow to fail fast with a ConfigError instead.

Parameters

ParameterTypeDescription
locConfigLOCConfig | undefinedThe LOC config to validate.

Returns

Promise<LOCConfigValidationResult>

Array of validation errors, or undefined if no errors occurred.

Example

const errors = await validateUserProvidedLOCConfig(locConfig);
if (!errors) return; // undefined means the config is valid
// Errors are addressed by field path, e.g.
// ["locConfig", "locBeneficiaryAllowList", "2"]; a prefix selects a group.
const allowlistErrors = getErrorsByFieldPath(errors, [
'locConfig',
'locBeneficiaryAllowList',
]);
for (const e of allowlistErrors ?? []) {
console.warn(
`${fieldPathToString(e.fieldPath)}: ${e.message}`,
e.invalidValue
);
}
throw new Error(`Invalid LOC config (${errors.length} problem(s))`);