Conditional validation using data annotations

I have a entity object which needs to be validated in my wcf project.The entity class contains two properties,viz,userId (int)and a type(string).
userId being a required field,has an attribute IsRequired=true.So it's a mandatory field.
type can have two possible values,viz, A and B.
However, as per requirement, if type is A then userId will be checked if present or not and if present it's numeric or not.
If type is B, then no validation should be performed on userId.
What could be an ideal solution to this conditional based validations?
I think we can go for an inherited attribute say IfPresent,inheriting from ValidationAttibute class and then apply this attribute on the top of Type property.

Can you please validate my proposal or if possible suggest any better solution to this problem?