Getting ready

RTTI attributes are a Delphi language feature that allows you to add metadata information to types and type members (comparable to C# attributes or Java annotations, to be clear). By attributes, you can add metadata information in a declarative way. An attribute is depicted by square brackets ([ ]) placed above the element it is used for.

Attributes do not modify the behavior of types or members by themselves, but, after it is associated, the attribute can be queried at runtime by using RTTI techniques (this topic has already been covered in the RTTI to the Rescue recipe), and you take appropriate actions when you think they are required.

Imagine the following scenario: we must proceed to register a client through a classic user registration form! How can we ensure, through the RTTI attributes, fields are correctly compiled?

Let's find out!