How these various validation libraries add this metadata to structures such as:
type Post struct {
Title string `valid:"alphanum,required"`
Message string `valid:"duck,ascii"`
AuthorIP string `valid:"ipv4"`
Date string `valid:"-"`
}
I am confused, Title property, type - string. Other than this, how can you simply add valid:"alphanum,required"Is this reflection used?
Are similar attributes in other languages?
[Required]
public int Title { get;set; }
source
share