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

Mustache mistakes "0" value for false #24

Open
S2MBO opened this issue Mar 11, 2015 · 2 comments
Open

Mustache mistakes "0" value for false #24

S2MBO opened this issue Mar 11, 2015 · 2 comments

Comments

@S2MBO
Copy link

S2MBO commented Mar 11, 2015

Applies to feature/refactor.

Say you have the following in your metaJSON

{
                "name" : "type",
                "base-type" : "number",
                "description" : "the type of product",
                "required" : 1, 
                "minValue" : 0,
                "maxValue" : 1
}

and you want to perform some validation, for example in Java:

        {{#minValue}}
        if (newValue < {{minValue}}) {
            throw new InvalidArgumentException("Number " + newValue + " is smaller than {{minValue}}.");
        }
        {{/minValue}}

the code block is never generated. In fact mustache, due to its JavaScript nature, seems to evals an integer "0" to a boolean "false".

A possible work-around for this could be havinge pre-defined mustache keys has[Min,Max][Length,Value,Key].

@netbe
Copy link
Contributor

netbe commented Mar 19, 2015

@S2MBO still valid?

@S2MBO
Copy link
Author

S2MBO commented Mar 19, 2015

Yes. This is still a problem. When I get to it, I might implement a fix.

S2MBO added a commit to S2MBO/metaJSON that referenced this issue Mar 19, 2015
…trings to mustache.

Integer zeros would be evaluated to false and not rendered by mustache.
S2MBO added a commit to S2MBO/metaJSON that referenced this issue Mar 19, 2015
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

No branches or pull requests

2 participants