Template:SanitiseBoolean: Difference between revisions
Appearance
AndrewSayers (talk | contribs) Created page with "<pre><onlyinclude>{{#switch: {{lc:{{{1|}}}}} | 0 | no | off | false | disabled = 0 | 1 | on | yes | true | enabled = 1 | Category:Pages with invalid booleans }}</onlyinclude></pre> <templatedata> { "params": { "1": { "label": "Value", "description": "Value to convert to a boolean", "example": "yes", "type": "unknown", "suggestedvalues": [ "0", "no", "false", "disabled", "1", "yes", "true", "enabled" ], "required..." |
AndrewSayers (talk | contribs) No edit summary |
||
Line 10: | Line 10: | ||
| true | | true | ||
| enabled = 1 | | enabled = 1 | ||
| [[Category:Pages with invalid booleans]] | | {{#if:{{{IgnoreInvalid}}}|{{#if:{{{IgnoreInvalid|}}}||[[Category:Pages with invalid booleans]]|}}}} | ||
}}</onlyinclude></pre> | }}</onlyinclude></pre> | ||
<templatedata> | <templatedata> | ||
Line 31: | Line 31: | ||
], | ], | ||
"required": true | "required": true | ||
}, | |||
"IgnoreInvalid": { | |||
"description": "If present, an invalid parameter will not cause this to be added to the \"Pages with invalid booleans\" category." | |||
} | } | ||
}, | }, |
Latest revision as of 16:25, 7 September 2025
<onlyinclude>{{#switch: {{lc:{{{1|}}}}} | 0 | no | off | false | disabled = 0 | 1 | on | yes | true | enabled = 1 | {{#if:{{{IgnoreInvalid}}}|{{#if:{{{IgnoreInvalid|}}}||[[Category:Pages with invalid booleans]]|}}}} }}</onlyinclude>
Convert boolean-like parameters ("no", "true" etc.) to 0 or 1, convert unknown values to the empty string. Please call this from other templates to sanitise your boolean values.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Value | 1 | Value to convert to a boolean
| Unknown | required |
IgnoreInvalid | IgnoreInvalid | If present, an invalid parameter will not cause this to be added to the "Pages with invalid booleans" category. | Unknown | optional |