I am using Ruby on Rails 3.2.9 and I would like to validate that the first char of a name (a String) is not a number (Integer). I am trying to use the following code:
class User < ActiveRecord::Base
validates_each :name do |record, attr, value|
record.errors.add(attr, 'cannot begin with a number') if ... # the first char is a number
end
end
How can I make that?
that will match any string whose first character is a number