Changeset 1463
- Timestamp:
- 01/07/07 04:00:26 (2 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/0.11/src/validator/AgaviNumberValidator.class.php
r1245 r1463 47 47 protected function validate() 48 48 { 49 $value = $this->getData($this->getArgument()); 49 $value =& $this->getData($this->getArgument()); 50 51 $hasExtraChars = false; 52 53 if(!$this->getParameter('no_locale', false)) { 54 if($locale = $this->getParameter('in_locale')) { 55 $locale = $this->getContext()->getTranslationManager()->getLocaleFromIdentifier($locale); 56 } else { 57 $locale = $this->getContext()->getTranslationManager()->getCurrentLocale(); 58 } 59 60 $value = AgaviDecimalFormatter::parse($value, $locale, $hasExtraChars); 61 } 50 62 51 63 switch(strtolower($this->getParameter('type'))) { 52 64 case 'int': 53 65 case 'integer': 54 $temp = (int) $value; 55 if(((string)$temp) !== ((string)$value) ) { 66 if(!is_int($value) || $hasExtraChars) { 56 67 $this->throwError('type'); 57 68 return false; … … 61 72 62 73 case 'float': 63 if(!is_ numeric($value)) {74 if(!is_float($value) || $hasExtraChars) { 64 75 $this->throwError('type'); 65 76 return false; … … 67 78 68 79 break; 80 } 81 82 switch(strtolower($this->getParameter('cast_to'))) { 83 case 'int': 84 case 'integer': 85 $value = (int) $value; 86 break; 87 88 case 'float': 89 case 'double': 90 $value = (float) $value; 91 break; 92 69 93 } 70 94

