In order to define a field with one dimension which contains Integers, used to define in the below format using domain models library.
class Sample
include DomainModel
field :numbers, :type => Integer, :collection => true
end
In the similar way how can I define a two dimensional array using Domain model?
Okay I have found a solution to your question in
domain_model
.When you include the
DomainModel
Module into your class it adds a class method calledvalidate
. This method allows you to specify custom validation in the context of the instance so to validate that an Array contains only numbers at any depth this would be you code:To validate that it contains only numbers in a 2 dimensional Array then