Comments (4)
Hi Steffen
I checked out your module yesterday and could not find a way to verify
if a string has a valid syntax path.
I expected
Data::DPath::Path->new( path => '!"ยง$%&/()=') to throw an error but no
matter what I send in as path iti s happily accepted.
Hmmm, they are normal paths, just looking a bit weird.
The only thing that's missing is that DPath does not find values when
tha path is not anchored with / at the beginning - I'm not sure what
semantics I planned or have.
Try attached test and see what I mean:
prove -vl strange-paths.t
Note how I split and nested the keys in $data according to the "/" in
your "garbage path".
It only fails with the un-anchored paths. Besides that it works.
Hi Steffen
thanks for the elaborate answer.
I have a web application where users can enter XPaths, Regular
Expressions, ... and hopefully soon to come .. DPaths
When I validate the users input all those modules provide the
possibility to "process" the input and in case of an invalid syntax an
error is thrown, which I re-present to the users as an error message.
In the case of Data::DPath no such validation "phase" seems available.
I thought perhaps that would be a sensible thing to add to make using
DPath more stable.
e.g.
Data::DPath::Path
. sub new {
. my $path_str = shift;
. if ($path_str =~ qr/^//xms) { die "Invalid DPath:Path syntax ..."; }
. }
from data-dpath.
Thanks. Currently I try to allow "relative" paths by anchoring them to root
which would make your "garbage paths" valid.
Can you think of any other path examples which should actually be wrong?
Otherwise my validate() function currently looks like always returning true...
from data-dpath.
Hi David,
I just rediscovered this issue. What's your current mindset on this?
Do you still need a validate() function?
I currently don't really know how to decide a path is valid as it can match crazy strings with paths that look similiarly crazy.
from data-dpath.
hey again,
I seem to have missed your question some time ago. :)
We could still use a validation method but I understand that it is not easy to implement. Even though paths might be very complex I suppose theyhave some kind of rule/grammar they follow.
ps: we are using Data::DPath extensively and are very happy so far.
from data-dpath.
Related Issues (9)
- Just a test HOT 3
- Number found where operator expected at {path}/warnings.pm line {line}, near "caller 1 HOT 3
- Name "main::INC" used only once: possible typo HOT 1
- weird behaviour, newline in $path HOT 20
- Can't select specific array item (question) HOT 13
- Implement a "container syntax for dpath chains" based on some balanced expression like this:
- Explosion of NYTProf cruft HOT 2
- escapes inside filter HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from data-dpath.