Rails validating full_name
问题 Hey... how would you validate a full_name field (name surname). 回答1: Consider names like: Ms. Jan Levinson-Gould Dr. Martin Luther King, Jr. Brett d'Arras-d'Haudracey Brüno Instead of validating the characters that are there, you might just want to ensure some set of characters is not present. For example: class User < ActiveRecord::Base validates_format_of :full_name, :with => /\A[^0-9`!@#\$%\^&*+_=]+\z/ # add any other characters you'd like to disallow inside the [ brackets ] #