mtedone / podam

PODAM - POjo DAta Mocker
https://mtedone.github.io/podam
MIT License
326 stars 749 forks source link

add support for @Pattern with BeanValidationStrategy #218

Open aviram26 opened 8 years ago

aviram26 commented 8 years ago

Currently got a warning: At the moment PODAM doesn't support @Pattern({})

I can do a PR if you can give me some hints about the way to achieve this (e.g. a way to override BeanValidationStrategy or attaching something to the factory)

Can be generated easily using https://github.com/mifmif/Generex

daivanov commented 8 years ago

Apparently, the warning should be replaced with an actual implementation.

daivanov commented 8 years ago

As you can see, a regular expression [A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,6}, which is supposed to be an email, results in the following string:

%3-肯=41/--1䗤2-橦-:/G=륇-椇/@;..벰//&amp#20;1-&amp#15;᲼-.ቇ@─-//텝&amp#0;Q1ⱓ3:&amp#30;/&amp#24;ꎷ@.2L/T.-/0./=//&amp#11;--A7340.V?&amp#29;'.;>> ?.N桫./掩M--K鿔3@H&amp#19;--&amp#24;7-瀶.2/&amp#22;얲!.Z>R2&amp#0;.DRO7--/.&amp#27;&amp#17;&amp#29;S:/U77_-偎E.8>3茰廔&amp#16;炑N:.6.!<@;줈.=94PJ&amp#23;&amp#18;見3&amp#23;I/࣊/&amp#31;?7.@'?/,.--燒@씜/$#ﱻT-꼼/_-..0캫俟㦛.뵮/☻-ചU꼶⑀W//뉄-.E-O/Y'ᦧ//2.-5.$I.-57桱-1-Ძ>--$0T&amp#5;//;T./(/I)E6.&amp#0;&amp#23;/3.-&amp#17;嵱J氨9//R/X-.-*&amp#23;22$&amp#11;鹽//ȷn&@졸6JT.>W@6/:O&amp#17;&amp#3;@-A&amp#19;E@PH5U/:/M/&amp#22;-/-1O:⾆/X0&amp#29;Q.&amp#21;//:V4T-6&amp#15;--23膴9-/'&amp#29;4/&amp#6;<E2- 6-&amp#11;:=!6ﲾ=$-6&amp#12;-6/ﱕ<&amp#28;;+Y?T5:襥CTZ1-/펦)掰///=20EF&amp#6;:=8ꐤ2-5P.4.2-≴ꛭ>V!00/G/.;Q/켢8&amp#24;I䀄풡909&amp#21;-1/?ᦶ7-/놟S?&amp#26;&amp#22;K..68/:-.-/䞋&amp#25;-῾U?.;9/&amp#0;Q&amp#30;.&amp#18;:&amp#22;/&amp#29;<&amp#20;>6⹣.X0B㟿/3-ꪛ-&amp#8;兵&amp#20;-./3-.YF

And also Generex doesn't support ^ and $ patterns.

aviram26 commented 8 years ago

You are right... I will look for other solutions and update if I find anything Thanks for the responsiveness :)

daivanov commented 8 years ago

There is also Xeger, but it never was released to Maven. One way could be adding Generex as a dependency any way and then encourage people to file issues to it and also do PR to Generex fixing obvious problems.