Answers.Body: <p>Not really documented anywhere, but <code>AttributeType::Number</code> can accept an array of options, including <code>min</code>, <code>max</code> and <code>decimal</code>.  You're looking for the last one.</p>
  
  <pre><code>AttributeType::Number =&gt; array('min' =&gt; 0, 'max' =&gt; 10, 'decimals' =&gt; 2);
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-04T02:45:27.350Z
Answers.LastActivityDate: 2017-07-04T02:45:27.350Z
Answers.UserDisplayName: Brad Bell
Body: <p>So I have a model attribute <code>attributeName</code> with an <code>AttributeType::Number</code></p>
  
  <p>I haven't implemented any personal validation rules yet, however when I run:
  <code>model-&gt;validate()</code>, 
  its giving me a <code>"attributeName must be an integer"</code> error. </p>
  
  <p>Is this just the default validation rule of the <code>AttributeType::Number</code>?  and if so, is there anything I can do to make it accept floats?</p>
  
  <p>I am trying to use this attribute for a price, I should note.</p>
  
  <p><a href="http://www.yiiframework.com/doc/api/1.1/CNumberValidator" rel="nofollow noreferrer">CNumberValidator</a> has an <code>integerOnly</code> attribute, so I tried setting <code>'integerOnly'=&gt;false</code> in the attribute declaration, to no avail. Not sure if its relevant, I think I might be grasping at straws. Any help would be greatly appreciated!</p>
  
Tags: <validation><models><attributetype>
Title: AttributeType::Number giving validation error "Must be an integer"
ThreadText: # AttributeType::Number giving validation error "Must be an integer"
  
  (Asked by: username_0 on 2017-07-03)
  
  So I have a model attribute `attributeName` with an `AttributeType::Number`
  
  I haven't implemented any personal validation rules yet, however when I run:
  `model->validate()`,
  its giving me a `"attributeName must be an integer"` error.
  
  Is this just the default validation rule of the `AttributeType::Number`? and if so, is there anything I can do to make it accept floats?
  
  I am trying to use this attribute for a price, I should note.
  
  [CNumberValidator](http://www.yiiframework.com/doc/api/1.1/CNumberValidator) has an `integerOnly` attribute, so I tried setting `'integerOnly'=>false` in the attribute declaration, to no avail. Not sure if its relevant, I think I might be grasping at straws. Any help would be greatly appreciated!
  
  **Tags:** validation, models, attributetype
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-07-04. Score: 1 | Accepted answer
  
  Not really documented anywhere, but `AttributeType::Number` can accept an array of options, including `min`, `max` and `decimal`. You're looking for the last one.
  
  ```
  AttributeType::Number => array('min' => 0, 'max' => 10, 'decimals' => 2);
  
  ```
  
  
  ---
  
  