Skip to content

BigInt value is not working #362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nirmal25990 opened this issue Feb 8, 2024 · 0 comments · Fixed by #378
Closed

BigInt value is not working #362

nirmal25990 opened this issue Feb 8, 2024 · 0 comments · Fixed by #378

Comments

@nirmal25990
Copy link

nirmal25990 commented Feb 8, 2024

When we pass BigInt value as fact. Getting this error.

Screenshot 2024-02-08 at 4 45 58 PM

Here is the sample code to reproduce this error.

    /**
     * Setup a new engine
     */
    const engine = new Engine();

    // define a rule for detecting the player has exceeded foul limits.  Foul out any player who:
    // (has committed 5 fouls AND game is 40 minutes) OR (has committed 6 fouls AND game is 48 minutes)
    engine.addRule({
      conditions: {
        any: [
          {
            all: [
              {
                fact: 'revenue',
                operator: 'greaterThan',
                value: 5000,
              },
            ],
          },
        ],
      },
      event: {
        // define the event to fire when the conditions evaluate truthy
        type: 'fouledOut',
        params: {
          message: 'Revenue is higher than the expected!',
        },
      },
    });

    /**
     * Define facts the engine will use to evaluate the conditions above.
     * Facts may also be loaded asynchronously at runtime; see the advanced example below
     */
    const facts = {
      revenue: BigInt(5001),
    };

    // Define success and failure handlers
    engine.on('success', () => {
      console.log('success');
    });

    engine.on('failure', () => {
      console.log('failure');
    });

    // Run the rule engine
    await engine.run(facts);
    
chris-pardy added a commit to chris-pardy/json-rules-engine that referenced this issue Oct 11, 2024
Change the call signature, leverage built-in formatting on console. Move debug enablement checks to file load.
Replaces CacheControl#363
Resolves CacheControl#362

Co-Author Nirmal Patel <nirmal259907@gmail.com>
chris-pardy added a commit to chris-pardy/json-rules-engine that referenced this issue Oct 11, 2024
Change the call signature, leverage built-in formatting on console. Move debug enablement checks to file load.
Replaces CacheControl#363
Resolves CacheControl#362

Co-Author Nirmal Patel <nirmal259907@gmail.com>
@chris-pardy chris-pardy mentioned this issue Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant