Conrad Taylor wrote:
Sijo, what is the correct format for a name? In any case, your regular
says that the format for the name should be a comma.
No, it says that the name should contain a comma (although your
brackets are superfluous).
validates_format_of :name, :with => /[,]/
is saying that the name should have the pattern, ‘,’. The definition
of ‘validates_format_of’ has the following documentation:
Validates whether the value of the specified attribute is of the
correct form by matching it against the regular expression provided.
His initial regular express had the correct syntax and there wasn’t a problem with
the brackets. However, he wasn’t using the correct regular expression for the type
of names that he wanted to store in his name field.