Question: So, I have a clip model with the following validation:

```
  class Clip < ActiveRecord::Base

  DESCRIPTION_MAX_LENGTH = 200
  validates_length_of :description, maximum: DESCRIPTION_MAX_LENGTH

  ....
  end

```

However, when editing a description on a clip I seem to be getting a validation error even though the description only has 92 characters. 

What am I doing wrong? It should be allowing descriptions of upto 200 characters in length. 

**Edit (error message included):** 

```
Description is too long (maximum is 200 characters)"

```

Answer: 
ActiveModel::Validations::HelperMethods.validates\_length\_of is the old fashioned way of validating the length of a string. You better go with ActiveModel::Validations::ClassMethods.validates like:

```
    class Clip < ActiveRecord::Base
      validates :description, length: { maximum: 200 }
    end

```

Both validates methods end in calling the LengthValidator.

[APIdock ActiveModel::Validations::HelperMethods.validates\_length\_of](http://apidock.com/rails/ActiveModel/Validations/HelperMethods/validates_length_of)

Btw., since the constant is only used in the validator, I wouldn't have a separate constant for the length value.
So, I found the solution. I am using a rich text editor to edit the description allowing users to add styling to the actual descriptions. 

However, because of this, this is what this clip has as a description:

When 2 is captured by

Therefor, the more styles you have in your description, the more characters will be added to description as html/css tags/styles

I had to make the validation 400.