Predloga:Valid
Purpose
Determines whether something is valid in a certain context. Currently only implemented for determining if a number is within the precision that Wikipedia expressions can handle.
Returns
true if the argument is valid, false if it is not.
Examples
{{valid|number=A}}= false (not a number){{valid|number=1234}}= true{{valid|number=+1234}}= true{{valid|number=-1234}}= true{{valid|number=(1234)}}= true (one pair of parenthesis is allowed){{valid|number=--1234}}= false (incorrect sign use){{valid|number=1234567890}}= true{{valid|number=12345678901234567890}}= false (too large){{valid|number=1.234567890}}= true{{valid|number=1.2345678901234567890}}= false (too many decimals)
Performance impact
Template:Valid returns "true" for a valid, single number (2+2 gives "false"), and allows scientific notation (such as: -3.45E-07). The precision limit is determined live, for whichever server is formatting the page, typically allowing 14-digit precision (plus trailing zeroes), but it does not detect extreme precision problems dropping minor end-digits:
- cannot reject: -10020030040050000000000000000.70, treated as -1.002003004005E+28
The template has been written with minimal markup text, and could be used 50,000-13,000 times per page, or less when all 30-digit numbers. Template:Valid is typically used at upper levels of other templates, so it is unlikely to trigger expansion-depth problems. However, it has an expansion-depth of 8 levels, and returns "false" if used when nested too deep inside other templates, such as at level 33 when the expansion depth limit is 40.
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.









