Pregunta

I try to validate in MongoMapper a string with:

key :title,       String, :require => true, :length => 4..30

And I got always the error "title is too short (minimum is 4 characters)" also when the string was longer than 4 chars.

If I try it with

key :title,       String, :require => true, :minimum => 4, :maximum => 30

and it work as excepted. Can someone explain why this happen or why the first thing is wrong?

¿Fue útil?

Solución

MongoMapper uses Activerecord validations. From their documentation: validates :password, :length => { :in => 6..20 } So you have to use :in to denote you are using a range. See http://guides.rubyonrails.org/active_record_validations_callbacks.html#length

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top