PHPackages                             icmbio/validate-xpath-expression - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. icmbio/validate-xpath-expression

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

icmbio/validate-xpath-expression
================================

v1.0.1(2mo ago)0451MITPHPCI passing

Since Apr 2Pushed 2mo agoCompare

[ Source](https://github.com/jotapeicmbio/validate-xpath-expression)[ Packagist](https://packagist.org/packages/icmbio/validate-xpath-expression)[ RSS](/packages/icmbio-validate-xpath-expression/feed)WikiDiscussions main Synced 4w ago

READMEChangelog (2)Dependencies (6)Versions (3)Used By (1)

Validate XPath Expression
=========================

[](#validate-xpath-expression)

[Português do Brasil](./README.pt-BR.md)

A small PHP library for validating and evaluating a focused XPath-like expression dialect against a value and an optional context array.

This project was inspired by the API style of the Python library [`znc-sistemas/xpath_validator`](https://github.com/znc-sistemas/xpath_validator). The PHP implementation in this repository is independent, but the public usage style follows the same idea of validating expressions against runtime values.

Why this project exists
-----------------------

[](#why-this-project-exists)

This repository isolates XPath-style validation behavior that was previously embedded in another project. The goal is to keep expression validation small, testable, reusable, and safe to evolve on its own.

Features
--------

[](#features)

- Static convenience API via `Xpath::validate(...)`
- Instance-based execution via `new Xpath(...)->execute()`
- Value placeholder support with `.`
- Context interpolation with `${name}`
- Built-in XPath-like functions mapped to PHP handlers
- Custom expression parser and evaluator
- No `eval()`
- Positive and rejection-oriented test coverage

Installation
------------

[](#installation)

If the package is published to Packagist, you can install it with:

```
composer require icmbio/validate-xpath-expression
```

If you are consuming the repository directly before publication, add it as a VCS repository in your `composer.json` and require the package from there.

Quick start
-----------

[](#quick-start)

```
