• Normalizes and validates an OracleJob definition

    Parameters

    Returns OracleJob

    A validated OracleJob instance

    If validation fails or job is invalid

    // From JSON string with comments
    const job1 = normalizeOracleJob(`{
    // Fetch BTC price
    "tasks": [
    {"httpTask": {"url": "https://api.coinbase.com/v2/prices/BTC-USD/spot"}}
    ]
    }`);

    // From plain object
    const job2 = normalizeOracleJob({
    tasks: [
    {httpTask: {url: "https://api.coinbase.com/v2/prices/BTC-USD/spot"}}
    ]
    });
    • Handles JSON strings with both inline (//) and block (/* */) comments
    • Validates task array existence and non-emptiness
    • Performs basic OracleJob schema validation
    • Uses regex pattern from https://regex101.com/r/B8WkuX/1 for comment stripping