Zend_Validate-Digits.xml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect2 id="zend.validate.set.digits">
  4. <title>Digits</title>
  5. <para>
  6. <classname>Zend_Validate_Digits</classname> validates if a given value contains only digits.
  7. </para>
  8. <sect3 id="zend.validate.set.digits.options">
  9. <title>Supported options for Zend_Validate_Digits</title>
  10. <para>
  11. There are no additional options for <classname>Zend_Validate_Digits</classname>:
  12. </para>
  13. </sect3>
  14. <sect3 id="zend.validate.set.digits.basic">
  15. <title>Validating digits</title>
  16. <para>
  17. To validate if a given value contains only digits and no other characters, simply call
  18. the validator like shown in this example:
  19. </para>
  20. <programlisting language="php"><![CDATA[
  21. $validator = new Zend_Validate_Digits();
  22. $validator->isValid("1234567890"); // returns true
  23. $validator->isValid(1234); // returns true
  24. $validator->isValid('1a234'); // returns false
  25. ]]></programlisting>
  26. <note>
  27. <title>Validating numbers</title>
  28. <para>
  29. When you want to validate numbers or numeric values, be aware that this validator
  30. only validates digits. This means that any other sign like a thousand separator or
  31. a comma will not pass this validator. In this case you should use
  32. <classname>Zend_Validate_Int</classname> or
  33. <classname>Zend_Validate_Float</classname>.
  34. </para>
  35. </note>
  36. </sect3>
  37. </sect2>