Hi Sashika,

Thanks for the update. Great,  that validation pattern works fine.

Regards,

*Senuwan Withana*
Software Engineer - Support Team | WSO2

Email : [email protected]
Mobile: 94773212853
Web: http://www.wso2.com



On Sat, Jan 6, 2018 at 11:43 AM, Sashika Wijesinghe <[email protected]>
wrote:

> Hi Senuwan,
>
> I have tried with the regex pattern you provided and I'm getting the same
> validation error as above. However, if I execute the given regex pattern in
> Mysql it gives the correct result as below. The reason for this behaviour
> is due to the differences in the metacharacters used in MySQL regex and
> Javascript regex.
>
> mysql> SELECT * FROM `Employee` WHERE `email`REGEXP
> '^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$';
> +-------+----------+-----------+---------+----------+------------------+
> | EmpID | LastName | FirstName | Address | City     | email            |
> +-------+----------+-----------+---------+----------+------------------+
> |   199 | DEDDEDE  | abcname   | testadd  | citytest | [email protected] |
> +-------+----------+-----------+---------+----------+------------------+
> 1 row in set (0.00 sec)
>
>
> To validate the email address in DSS you can use
> *^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$*
> regex pattern.
>
> Example:
>
>   <query id="addEmployeeEmail" useConfig="employee">
>       <sql>INSERT INTO Employee (EMpID,LastName,FirstName,Address,City,
> email) VALUES (:id,:Lname,:Fname,:Address,:city, :email);</sql>
>       <param name="id" sqlType="INTEGER"/>
>       <param name="Lname" sqlType="STRING"/>
>       <param name="Fname" sqlType="STRING"/>
>       <param name="Address" sqlType="STRING"/>
>       <param name="city" sqlType="STRING"/>
>       <param name="email" sqlType="STRING">
>          <validatePattern pattern="^([0-9a-zA-Z]([-.\w]*
> [0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$"/>
>       </param>
>    </query>
>
> Could you please try using the given regex pattern to validate the email
> address in your data service?
>
> Regards,
> Sashika
>
> On Fri, Jan 5, 2018 at 10:50 PM, Senuwan Withana <[email protected]> wrote:
>
>> Hi Team,
>>
>> I found an issue when validating the email id using the WSO2 DSS.  I have
>> used below mentioned pattern.
>>
>>
>> When I executed my API I got error like following:
>>
>> Nested Exception:-
>> Pattern {^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$} is expected
>> Field Name: CUSTOMER_EMAIL
>> Field Value: [email protected]
>>
>>
>> Kindly give the suggestion to over come the mentioned issue.
>>
>> *Full log  attached below.*
>>
>> ​
>>
>> [2018-01-05 22:42:58,397] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "POST /carproduction HTTP/1.1[\r][\n]"
>> [2018-01-05 22:42:58,397] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "cache-control: no-cache[\r][\n]"
>> [2018-01-05 22:42:58,397] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "Postman-Token: ee0d92e3-e410-4bb3-b0c2-434041
>> ff1029[\r][\n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "Content-Type: application/xml[\r][\n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "User-Agent: PostmanRuntime/6.4.1[\r][\n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "Accept: */*[\r][\n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "Host: localhost:8280[\r][\n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "accept-encoding: gzip, deflate[\r][\n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "content-length: 810[\r][\n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "Connection: keep-alive[\r][\n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "[\r][\n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "  <CarAssemblingInsertOperation>[\n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "                        <CUSTOMER_NAME>Samantha123
>> Perera</CUSTOMER_NAME>[\n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "                        <CUSTOMER_EMAIL>[email protected]
>> </CUSTOMER_EMAIL>[\n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "                        <CAR_MODEL>Alto</CAR_MODEL>[\n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "                        <BODY_COLOR>blue</BODY_COLOR>[
>> \n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "                        <ENGINE_CAPACITY>800</ENGINE_C
>> APACITY>[\n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "                        <INTERIOR_MATERIAL>leather</IN
>> TERIOR_MATERIAL>[\n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "                        <INTERIOR_COLOR>Pink</INTERIOR
>> _COLOR>[\n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "                        <TIRE_SIZE>5T</TIRE_SIZE>[\n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "                        <SUN_ROOF>Yes</SUN_ROOF>[\n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "                        <HEATED_LEATHER_SEATS>Yes</HEA
>> TED_LEATHER_SEATS>[\n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "                        <NAVIGATION>No</NAVIGATION>[\n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "                        <AUTOMATIC_TAILGATE>No</AUTOMA
>> TIC_TAILGATE>[\n]"
>> [2018-01-05 22:42:58,398] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-2 >> "    </CarAssemblingInsertOperation>"
>> [2018-01-05 22:42:58,403] [EI-Core] DEBUG - wire HTTP-Sender I/O
>> dispatcher-3 << "POST /services/CARAPP HTTP/1.1[\r][\n]"
>> [2018-01-05 22:42:58,403] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-3 >> "POST /services/CARAPP HTTP/1.1[\r][\n]"
>> [2018-01-05 22:42:58,405] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-3 >> "SOAPAction: urn:AddDetails[\r][\n]"
>> [2018-01-05 22:42:58,405] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-3 >> "Accept: */*[\r][\n]"
>> [2018-01-05 22:42:58,405] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-3 >> "Postman-Token: ee0d92e3-e410-4bb3-b0c2-434041
>> ff1029[\r][\n]"
>> [2018-01-05 22:42:58,405] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-3 >> "cache-control: no-cache[\r][\n]"
>> [2018-01-05 22:42:58,405] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-3 >> "accept-encoding: gzip, deflate[\r][\n]"
>> [2018-01-05 22:42:58,405] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-3 >> "Content-Type: text/xml[\r][\n]"
>> [2018-01-05 22:42:58,405] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-3 >> "Transfer-Encoding: chunked[\r][\n]"
>> [2018-01-05 22:42:58,405] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-3 >> "Host: localhost:8280[\r][\n]"
>> [2018-01-05 22:42:58,405] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-3 >> "Connection: Keep-Alive[\r][\n]"
>> [2018-01-05 22:42:58,405] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-3 >> "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"
>> [2018-01-05 22:42:58,405] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-3 >> "[\r][\n]"
>> [2018-01-05 22:42:58,406] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-3 >> "698[\r][\n]"
>> [2018-01-05 22:42:58,406] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-3 >> "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope
>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:dat="
>> http://ws.wso2.org/dataservice";><soapenv:Header><dummyvalue xmlns="
>> http://ws.apache.org/ns/synapse";>12</dummyvalue></soa
>> penv:Header><soapenv:Body><p:AddDetails xmlns:p="http://ws.wso2.org/da
>> taservice"><!--Exactly 1 occurrence--><xs:CUSTOMER_NAME xmlns:xs="
>> http://ws.wso2.org/dataservice";>Samantha123
>> Perera</xs:CUSTOMER_NAME><!--Exactly 1 occurrence--><xs:CUSTOMER_EMAIL
>> xmlns:xs="http://ws.wso2.org/dataservice";>[email protected]</xs:CUSTOMER_EMAIL><!--Exactly
>> 1 occurrence--><xs:CAR_MODEL xmlns:xs="http://ws.wso2.org/dataservice
>> ">Alto</xs:CAR_MODEL><!--Exactly 1 occurrence--><xs:BODY_COLOR xmlns:xs="
>> http://ws.wso2.org/dataservice";>blue</xs:BODY_COLOR><!--Exactly 1
>> occurrence--><xs:ENGINE_CAPACITY xmlns:xs="http://ws.wso2.org/dataservice
>> ">800</xs:ENGINE_CAPACITY><!--Exactly 1 occurrence--><xs:INTERIOR_MATERIAL
>> xmlns:xs="http://ws.wso2.org/dataservice"/><!--Exactly 1
>> occurrence--><xs:INTERIOR_COLOR xmlns:xs="http://ws.wso2.org/dataservice
>> ">Pink</xs:INTERIOR_COLOR><!--Exactly 1 occurrence--><xs:TIRE_SIZE
>> xmlns:xs="http://ws.wso2.org/dataservice";>5T</xs:TIRE_SIZE><!--Exactly 1
>> occurrence--><xs:SUN_ROOF xmlns:xs="http://ws.wso2.org/dataservice
>> ">Yes</xs:SUN_ROOF><!--Exactly 1 occurrence--><xs:HEATED_LEATHER_SEATS
>> xmlns:xs="http://ws.wso2.org/dataservice";>Yes</xs:HEATED_LEATHER_SEATS><!--Exactly
>> 1 occurrence--><xs:NAVIGATION xmlns:xs="http://ws.wso2.org/dataservice
>> ">No</xs:NAVIGATION><!--Exactly 1 occurrence--><xs:AUTOMATIC_TAILGATE
>> xmlns:xs="http://ws.wso2.org/dataservice";>No</xs:AUTOMATIC_T
>> AILGATE></p:AddDetails></soapenv:Body></soapenv:Envelope>[\r][\n]"
>> [2018-01-05 22:42:58,406] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-3 >> "0[\r][\n]"
>> [2018-01-05 22:42:58,406] [EI-Core] DEBUG - wire HTTP-Listener I/O
>> dispatcher-3 >> "[\r][\n]"
>> [2018-01-05 22:42:58,405] [EI-Core] DEBUG - wire HTTP-Sender I/O
>> dispatcher-3 << "SOAPAction: urn:AddDetails[\r][\n]"
>> [2018-01-05 22:42:58,407] [EI-Core] DEBUG - wire HTTP-Sender I/O
>> dispatcher-3 << "Accept: */*[\r][\n]"
>> [2018-01-05 22:42:58,407] [EI-Core] DEBUG - wire HTTP-Sender I/O
>> dispatcher-3 << "Postman-Token: ee0d92e3-e410-4bb3-b0c2-434041
>> ff1029[\r][\n]"
>> [2018-01-05 22:42:58,407] [EI-Core] DEBUG - wire HTTP-Sender I/O
>> dispatcher-3 << "cache-control: no-cache[\r][\n]"
>> [2018-01-05 22:42:58,407] [EI-Core] DEBUG - wire HTTP-Sender I/O
>> dispatcher-3 << "accept-encoding: gzip, deflate[\r][\n]"
>> [2018-01-05 22:42:58,407] [EI-Core] DEBUG - wire HTTP-Sender I/O
>> dispatcher-3 << "Content-Type: text/xml[\r][\n]"
>> [2018-01-05 22:42:58,407] [EI-Core] DEBUG - wire HTTP-Sender I/O
>> dispatcher-3 << "Transfer-Encoding: chunked[\r][\n]"
>> [2018-01-05 22:42:58,407] [EI-Core] DEBUG - wire HTTP-Sender I/O
>> dispatcher-3 << "Host: localhost:8280[\r][\n]"
>> [2018-01-05 22:42:58,407] [EI-Core] DEBUG - wire HTTP-Sender I/O
>> dispatcher-3 << "Connection: Keep-Alive[\r][\n]"
>> [2018-01-05 22:42:58,407] [EI-Core] DEBUG - wire HTTP-Sender I/O
>> dispatcher-3 << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"
>> [2018-01-05 22:42:58,407] [EI-Core] DEBUG - wire HTTP-Sender I/O
>> dispatcher-3 << "[\r][\n]"
>> [2018-01-05 22:42:58,407] [EI-Core] DEBUG - wire HTTP-Sender I/O
>> dispatcher-3 << "698[\r][\n]"
>> [2018-01-05 22:42:58,407] [EI-Core] DEBUG - wire HTTP-Sender I/O
>> dispatcher-3 << "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope
>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:dat="
>> http://ws.wso2.org/dataservice";><soapenv:Header><dummyvalue xmlns="
>> http://ws.apache.org/ns/synapse";>12</dummyvalue></soa
>> penv:Header><soapenv:Body><p:AddDetails xmlns:p="http://ws.wso2.org/da
>> taservice"><!--Exactly 1 occurrence--><xs:CUSTOMER_NAME xmlns:xs="
>> http://ws.wso2.org/dataservice";>Samantha123
>> Perera</xs:CUSTOMER_NAME><!--Exactly 1 occurrence--><xs:CUSTOMER_EMAIL
>> xmlns:xs="http://ws.wso2.org/dataservice";>[email protected]</xs:CUSTOMER_EMAIL><!--Exactly
>> 1 occurrence--><xs:CAR_MODEL xmlns:xs="http://ws.wso2.org/dataservice
>> ">Alto</xs:CAR_MODEL><!--Exactly 1 occurrence--><xs:BODY_COLOR xmlns:xs="
>> http://ws.wso2.org/dataservice";>blue</xs:BODY_COLOR><!--Exactly 1
>> occurrence--><xs:ENGINE_CAPACITY xmlns:xs="http://ws.wso2.org/dataservice
>> ">800</xs:ENGINE_CAPACITY><!--Exactly 1 occurrence--><xs:INTERIOR_MATERIAL
>> xmlns:xs="http://ws.wso2.org/dataservice"/><!--Exactly 1
>> occurrence--><xs:INTERIOR_COLOR xmlns:xs="http://ws.wso2.org/dataservice
>> ">Pink</xs:INTERIOR_COLOR><!--Exactly 1 occurrence--><xs:TIRE_SIZE
>> xmlns:xs="http://ws.wso2.org/dataservice";>5T</xs:TIRE_SIZE><!--Exactly 1
>> occurrence--><xs:SUN_ROOF xmlns:xs="http://ws.wso2.org/dataservice
>> ">Yes</xs:SUN_ROOF><!--Exactly 1 occurrence--><xs:HEATED_LEATHER_SEATS
>> xmlns:xs="http://ws.wso2.org/dataservice";>Yes</xs:HEATED_LEATHER_SEATS><!--Exactly
>> 1 occurrence--><xs:NAVIGATION xmlns:xs="http://ws.wso2.org/dataservice
>> ">No</xs:NAVIGATION><!--Exactly 1 occurrence--><xs:AUTOMATIC_TAILGATE
>> xmlns:xs="http://ws.wso2.org/dataservice";>No</xs:AUTOMATIC_T
>> AILGATE></p:AddDetails></soapenv:Body></soapenv:Envelope>[\r][\n]"
>> [2018-01-05 22:42:58,407] [EI-Core] DEBUG - wire HTTP-Sender I/O
>> dispatcher-3 << "0[\r][\n]"
>> [2018-01-05 22:42:58,407] [EI-Core] DEBUG - wire HTTP-Sender I/O
>> dispatcher-3 << "[\r][\n]"
>> [2018-01-05 22:42:58,409] [EI-Core] ERROR - DBInOutMessageReceiver Error
>> in in-out message receiver
>> DS Code: VALIDATION_ERROR
>> Nested Exception:-
>> javax.xml.stream.XMLStreamException: DS Code: VALIDATION_ERROR
>> Source Data Service:-
>> Name: CARAPP
>> Location: /CARAPP.dbs
>> Description: Connected CAR app data service.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Default Namespace: http://ws.wso2.org/dataservice
>> Current Request Name: AddDetails
>> Current Params: {TIRE_SIZE=5T, CUSTOMER_NAME=Samantha123 Perera,
>> INTERIOR_COLOR=Pink, INTERIOR_MATERIAL=, HEATED_LEATHER_SEATS=Yes,
>> [email protected], ENGINE_CAPACITY=800, SUN_ROOF=Yes,
>> AUTOMATIC_TAILGATE=No, NAVIGATION=No, CAR_MODEL=Alto, BODY_COLOR=blue}
>> Nested Exception:-
>> Pattern {^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$} is expected
>> Field Name: CUSTOMER_EMAIL
>> Field Value: [email protected]
>>
>>
>> at org.wso2.carbon.dataservices.core.dispatch.SingleDataService
>> Request.processRequest(SingleDataServiceRequest.java:75)
>> at org.wso2.carbon.dataservices.core.dispatch.DataServiceReques
>> t.dispatch(DataServiceRequest.java:357)
>> at org.wso2.carbon.dataservices.core.DataServiceProcessor.dispa
>> tch(DataServiceProcessor.java:41)
>> at org.wso2.carbon.dataservices.core.DBInOutMessageReceiver.inv
>> okeBusinessLogic(DBInOutMessageReceiver.java:57)
>> at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.
>> invokeBusinessLogic(AbstractInOutSyncMessageReceiver.java:42)
>> at org.apache.axis2.receivers.AbstractMessageReceiver.receive(A
>> bstractMessageReceiver.java:110)
>> at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
>> at org.apache.synapse.transport.passthru.ServerWorker.processEn
>> tityEnclosingRequest(ServerWorker.java:404)
>> at org.apache.synapse.transport.passthru.ServerWorker.run(Serve
>> rWorker.java:151)
>> at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.
>> run(NativeWorkerPool.java:172)
>> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPool
>> Executor.java:1142)
>> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoo
>> lExecutor.java:617)
>> at java.lang.Thread.run(Thread.java:748)
>> Caused by: javax.xml.stream.XMLStreamException: DS Code: VALIDATION_ERROR
>> Source Data Service:-
>> Name: CARAPP
>> Location: /CARAPP.dbs
>> Description: Connected CAR app data service.
>>
>> Thanks,
>>
>> *Senuwan Withana*
>> Software Engineer - Support Team | WSO2
>>
>> Email : [email protected]
>> Mobile: 94773212853
>> Web: http://www.wso2.com
>>
>>
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
>
> *Sashika WijesingheSoftware Engineer - QA Team*
> Mobile : +94 (0) 774537487
> [email protected]
>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to