Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Purpose  





2 Returns  





3 Examples  





4 Performance impact  














Template:Valid






Afrikaans
العربية


Bosanski
Català
Dansk
الدارجة
فارسی
Føroyskt
Հայերեն
Ilokano
Bahasa Indonesia
Jawa
ि
Македонски
Minangkabau

Português
Română

Scots
Simple English
Slovenčina
Slovenščina
کوردی
Svenska
Taqbaylit
اردو
Tiếng Vit
Yorùbá

 

Edit links
 









Template
Talk
 

















Read
View source
View history
 








Tools
   


Actions  



Read
View source
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 




In other projects  



Wikibooks
Wikiversity
 
















Appearance
   

 





Permanently protected template

From Wikipedia, the free encyclopedia
 


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.


Retrieved from "https://en.wikipedia.org/w/index.php?title=Template:Valid&oldid=772121014"

Category: 
Wikipedia utility templates
Hidden category: 
Wikipedia template-protected templates
 



This page was last edited on 25 March 2017, at 12:38 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki