I have a string property on an entity that I would like to mark as required. For example,
public class Product
{
public virtual string Name { get; set; }
}
In my mappings, I can declare Name as required (using Fluent NHibernate):
mapping.Map(x => x.Name).Required();
However, this only restricts the string from being null. If I assign it to String.Empty, NHibernate will happily store the value of "" into the database.
My question is, is there a way of enforcing a minimum length for strings? For example, in this case, a product name should be at least 3 characters. Or will my business logic need to handle this instead of NHibernate?