Skip to content
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

fact to evaluate expression #59

Closed
byronhogoboom opened this issue Nov 13, 2017 · 2 comments
Closed

fact to evaluate expression #59

byronhogoboom opened this issue Nov 13, 2017 · 2 comments
Labels

Comments

@byronhogoboom
Copy link

I want to be able to do math in a fact. Adding to the trickiness the expression variables have different path. eg: i have object obj that has 2 sub objects a and b and i want to do a fact: obj.a.x * obj.b.y.

Is this possible with custom fact?

@CacheControl
Copy link
Owner

CacheControl commented Nov 13, 2017

@byronhogoboom You can do any computations you want inside a custom fact. It is important to remember that the output the fact returns should be consistent based on the input parameters. So if you are multiplying the values of your params together, or other fact values, that should be fine. If you were doing something that would cause the fact results to vary given the exact same params (like multiplying by a random number, for example), that can be done but is strongly discouraged as it requires you to disable fact caching and incur a performance hit.

I'd suggest doing a quick spike by building off one of the examples to prove out your use case. If you run into problems just paste the snippet in here and I'll try and help.

@fergusonIyara
Copy link

Hello, please is there an example pointing to a custom fact?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants