nhibernate validation

Posts   
 
    
costab
User
Posts: 36
Joined: 21-Aug-2010
# Posted on: 26-Jul-2011 00:38:34   

Is it possible to have llblgen pro generate nhibernate validation attributes (more or less out of the box) ?

Here is an example from this link: http://nhforge.org/wikis/validator/nhibernate-validator-1-0-0-documentation.aspx

    
public class Address
{
    [NotNull]
    public static string blacklistedZipCode;
    
    // field a not null string of 20 characters maximum
    [Length(Max = 20), NotNull]
    private string country;
    private long id;

For instance, I want to apply the Length attribute only to the varchar/string fields without going to each and every single varchar field.

Update:

I found this post: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=18323&HighLight=1

It looks like it's coming. When can we get our hands on version 3.5?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 26-Jul-2011 03:57:46   

Today, you have a couple of options:

A. Use the attribute system. Then you can use some macros. There are some things you can't define with macros so you will need to define this per-entity/field. After all, very often the definition of some field doesn't define its validation rule: you may have a field with length 50, but maybe you need to reduce it to 30 in validation, etc.

B. You can write a custom template that generate buddy classes where you can define such attributes via the template language. Example: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=19498 Additionally you can write your own Setting system, so you can set custom settings in your entity/field and interpret that in your custom template. For example you could define a RegularExpressionToValidate setting and use it in your fields so you can use that information to generate custom code. (more info...).

costab wrote:

It looks like it's coming. When can we get our hands on version 3.5

I don't have a real estimate for 3.5. I will ask.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 26-Jul-2011 09:11:11   

v3.5 is scheduled to go beta at the end of the year, maybe january 2012.

Frans Bouma | Lead developer LLBLGen Pro