public function setValue($val)
 {
     $this->value = $val;
     if (is_array($val)) {
         $this->fieldCurrency->setValue($val['Currency']);
         $this->fieldAmount->setValue($val['Amount']);
     } elseif ($val instanceof DBMoney) {
         $this->fieldCurrency->setValue($val->getCurrency());
         $this->fieldAmount->setValue($val->getAmount());
     }
     // @todo Format numbers according to current locale, incl.
     //  decimal and thousands signs, while respecting the stored
     //  precision in the database without truncating it during display
     //  and subsequent save operations
     return $this;
 }
 protected function checkInputValidation($locale, $tests)
 {
     i18n::set_locale($locale);
     $field = new NumericField('Number');
     $validator = new RequiredFields('Number');
     foreach ($tests as $input => $output) {
         // Both decimal and thousands B
         $field->setValue($input);
         if ($output === false) {
             $this->assertFalse($field->validate($validator), "Expect validation to fail for input {$input} in locale {$locale}");
             $this->assertEquals(0, $field->dataValue(), "Expect invalid value to be rewritten to 0 in locale {$locale}");
             // Even invalid values shouldn't be rewritten
             $this->assertEquals($this->clean($input), $field->Value(), "Expected input {$input} to be saved in the field in locale {$locale}");
         } else {
             $this->assertTrue($field->validate($validator), "Expect validation to succeed for {$input} in locale {$locale}");
             $this->assertEquals($output, $field->dataValue(), "Expect value {$input} to be mapped to {$output} in locale {$locale}");
         }
     }
 }