tags:

views:

64

answers:

1

Is it possible to set a requirement in WCF that a specific string datamember have a maximum length?

I'm essentially wanting to do some basic validation, and enhancing the implicit documentation that WSDL gives you.

I'm pretty sure that its possible when writing raw WSDL, but am not sure if you can do it in WCF using attributes etc.

And related, require that an array property have at least one element in it...

+2  A: 

No, to my knowledge, that's not possible - at least not yet. There is that concept of Data annotations floating around, being supported by ASP.NET dynamic data and now also by the Silverlight RIA Services, but in "pure" WCF, I don't know of any such means of limiting the length of a string in your DataContract, or requiring an array to have at least one members.

At least not in a declarative way (i.e. with attributes on your data contract).

There are a few things you can do on the data contract, like require an attribute to be present and such, but those are very limited in scope.

marc_s
Yes, that's what I was thinking. Thanks for clarifying.
Gareth