DataAnnotations Custom Validation

17 Nov 2009

I am putting this here because it took me way to long to find this information today.

Reference Links for this information:
[custom-validation-attributes]
[msdn]

To create a custom DataAnnotations validation attribute inherit from ValidationAttribute and implement IsValid.

public class CustomAttributeName : ValidationAttribute
{
    public override bool IsValid(object value)
    {
        bool validFlag = false;
        // perform validation here
        if (validFlag)
            return true;
        else
            return false;
    }
}

In the Model Validation Meta class use the custom validation attribute like this.

[MetadataType(typeof(EntityMetadata))]
public partial class Entity
{
    public class EntityMetadata
    {
        [CustomAttributeName(ErrorMessage=" [Required] ")]
        public object FieldName { get; set; }
    }
}

Wonderful Weekend

9 Nov 2009

I had quite a wonderful weekend. The weather was unseasonably warm for November, Saturday was almost 70°F and Sunday was 75°F. I raked a lot of leaves over the two days so I feeling kind of sore right now. Saturday the wife and I got out for dinner alone and that was real nice. One thing that is hard to remember to do is to slow down and not feel rushed when the kids aren’t with us. We did a little shopping and then we home and watched movies until we were falling asleep on the couch.

A friend of mine pointed me at a new PC game called Torchlight. Torchlight is a lot like Blizzard’s Diablo games which I loved. I have been playing Torchlight since Friday night and I have been having a total blast.

Sunday the Bears showed they really need to rework the offensive line as well as the defense. I think the reason why the Bears are having so much trouble running the ball this year is they aren’t opening up any lanes for the runners.  Its great we have a good quarterback finally but if the offensive line can’t open any holes to run and they can’t block well enough to give him time to throw the ball we don’t have much hope. The defense has suffered several key players being injured so its really a suboptimal group on the field. For a Bears fan to see the defense play so badly is a heart breaker. The Bears are 4 and 4 now and I don’t see the hope of much improvement over the rest of the season.

Smartphone Competition

28 Oct 2009

I watched the demo video at engadget of the new Motorola Droid phone. I must say I was pretty impressed. Droid won’t get me to switch from my iPhone for serveral reasons. I love the multimedia functionality of the iPhone, the apps and games I use, and easy sync/management with my home computer.

However there are several features of the Motorola Droid phone I would love to see on the iPhone.

  • A combined inbox view for email accounts
  • The new Google Maps for Mobile software
  • The doc and car doc accessories and the automatic mode change

If the iPhone had the new Google Maps for Mobile and a car dock I would order that right now.  The home dock for the Motorola Droid is really cool to.

I hope some competition drives Apple to continue to make the iPhone the best mobile device.

AT&T 3G Service

27 Sep 2009

I usually check my email on my iPhone when I am getting ready for work in the morning. Thursday as I was using my phone I noticed that I had a 3G signal at my house. I was pretty excited about that. I commute to work in Bloomington, IL. which has had 3G service for a couple of years but I live near Champaign, IL. which didn’t have 3G service. I couldn’t understand why Champaign didn’t have 3G service since its the home of the U of I one of the premier universities for engineering in the country.

Now when I am in Champaign and I want to look something up on my phone I won’t have to wait on the dreadfully slow Edge connection anymore.

Test Post

18 Sep 2009

Testing a code highlighter plugin.


Lorem ipsum...
SELECT *
FROM Products
WHERE Price > 19.99