HighTechTalks DotNet Forums  

RegEx validation using attibutes

ASP.net Web Services microsoft.public.dotnet.framework.aspnet.webservices


Discuss RegEx validation using attibutes in the ASP.net Web Services forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Steve James
 
Posts: n/a

Default RegEx validation using attibutes - 05-17-2006 , 03:11 PM






Is there a way to use a regular expression to validate a string in an
object/soap message passed to a web service without performing a full
schema validation? What I would like to do is something like:


public class WebServiceRequest
{

private string _aString;

[RegexValidation( Pattern="<Regular Expression goes here>")]
public string AString
{
get{ return _aString; }
set{ _aString = value; }
}
}

Does such an attribute or other construct exist which causes the
property to be validated against a regular expression by the web
service infrastructure automatically when the soap request is
deserialized?

Steve


Reply With Quote
  #2  
Old   
Gaurav Vaish \(EduJini.IN\)
 
Posts: n/a

Default Re: RegEx validation using attibutes - 05-17-2006 , 11:51 PM






Which namespace does the attribute RegexValidationAttribute belong to?
I don't think it's in the SDK...

In anycase, WS engine would not validate the values even if you have a
custom attribute like this.



--
Happy Hacking,
Gaurav Vaish
http://www.mastergaurav.org
http://www.edujini.in
-------------------


"Steve James" <steve.s.james (AT) gmail (DOT) com> wrote

Quote:
Is there a way to use a regular expression to validate a string in an
object/soap message passed to a web service without performing a full
schema validation? What I would like to do is something like:


public class WebServiceRequest
{

private string _aString;

[RegexValidation( Pattern="<Regular Expression goes here>")]
public string AString
{
get{ return _aString; }
set{ _aString = value; }
}
}

Does such an attribute or other construct exist which causes the
property to be validated against a regular expression by the web
service infrastructure automatically when the soap request is
deserialized?

Steve




Reply With Quote
  #3  
Old   
Steve James
 
Posts: n/a

Default Re: RegEx validation using attibutes - 05-18-2006 , 04:08 PM



The [RegexValidation( Pattern="<Regular Expression goes here>")]
attribute doesn't exist - I made it up. I probably didn't make it clear
in my original post, but this is the type of construct I would like to
use if there is one. Just as you can control Xml serialization and
deserialization with attributes such as XmlIgnore and XmlElement I
thought there may be something similar to match a property against a
regular expression.

Steve


Reply With Quote
  #4  
Old   
Gaurav Vaish \(EduJini.IN\)
 
Posts: n/a

Default Re: RegEx validation using attibutes - 05-18-2006 , 10:15 PM



Not possible.
WS Engine will not do any such checks.

--
Happy Hacking,
Gaurav Vaish
http://www.mastergaurav.org
http://www.edujini.in
-------------------


"Steve James" <steve.s.james (AT) gmail (DOT) com> wrote

Quote:
The [RegexValidation( Pattern="<Regular Expression goes here>")]
attribute doesn't exist - I made it up. I probably didn't make it clear
in my original post, but this is the type of construct I would like to
use if there is one. Just as you can control Xml serialization and
deserialization with attributes such as XmlIgnore and XmlElement I
thought there may be something similar to match a property against a
regular expression.

Steve




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.