Array of parameter specifications:
Object with getParam method (e.g., URI instance)
Result.Ok with all parameters or Result.Err with missing params message
const uri = URI.from('https://api.com?user=alice&page=1');
// Required and optional params with defaults
const result = getParamsResult(
['user', { page: '1' }, { limit: param.OPTIONAL }],
uri
);
if (result.isOk()) {
const { user, page, limit } = result.unwrap();
// user: 'alice', page: '1', limit: undefined
}
// Custom error message
const result2 = getParamsResult(
['apiKey', 'secret', (...missing) => `Auth failed: missing ${missing.join(', ')}`],
uri
);
Retrieves multiple parameters with type-safe Result handling and defaults.
Extracts multiple parameters from an object with getParam method (like URI), supporting required params, optional params, and default values. Returns Result.Err if any required parameters are missing.