Code Monkey home page Code Monkey logo

Comments (4)

davewood avatar davewood commented on July 4, 2024

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.

renormalist avatar renormalist commented on July 4, 2024

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.

renormalist avatar renormalist commented on July 4, 2024

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.

davewood avatar davewood commented on July 4, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.