I'm not sure if i understand your question right, but you asked where the {attribute} came from:
Some validators introduce placeholders like the {attribute} in your example. If validation fails, they will be replaced with the attribute name. So if no name was entered and your message is 'Please enter a valid {attribute}.' the error message will be "Please enter a valid name".
While the {attribute} placeholder can be used with every validator, some of them introduce even more placeholders. For example with the CStringValidator you can use {min}, {max} or {length}. They will be replace with the number of minimum, maximum or exact characters respecitvely.
Here's an example:
array('firstname,lastname', 'string', 'min'=>3,
'tooShort'=>'Your {attribute} must contain at least {min} letters.'
),
This will give "Your firstname must contain at least 3 letters." if the users enters less than 3 letters. This has the advantage that if you change the min parameter, your message will automatically be updated. So it's less error prone.