PHPackages                             alinandrei/registration\_number\_validator - 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. alinandrei/registration\_number\_validator

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

alinandrei/registration\_number\_validator
==========================================

1.0.1(5mo ago)03PHPPHP ^8.1

Since Oct 10Pushed 5mo agoCompare

[ Source](https://github.com/alinescu16/statamic_registration_number_validator)[ Packagist](https://packagist.org/packages/alinandrei/registration_number_validator)[ RSS](/packages/alinandrei-registration-number-validator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Registration Number Validator for Statamic
==========================================

[](#registration-number-validator-for-statamic)

A robust Statamic addon to validate company registration numbers (VAT, CUI, etc.) directly on your frontend forms. This addon integrates with VIES and country-specific validators (RO, DE, etc.) to ensure data accuracy before form submission.

Features
--------

[](#features)

- **Real-time Validation:** Validates registration numbers against VIES and national databases.
- **Frontend Ready:** Includes a pre-styled Vue component for instant usage ("Plug &amp; Play").
- **Headless API:** Exposes a JSON endpoint for fully custom UI implementations (e.g., Alpine.js).
- **Data Enrichment:** Retrieves and autofills company details (Name, Address, Registration Date) upon successful validation.
- **Multi-Country Support:** Specialized validation logic for Romania (RO), Germany (DE), and generic EU VIES validation.

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

[](#installation)

Install the addon via Composer:

```
composer require alinandrei/registration-number-validator

```

After installation, publish the assets (required for the Plug &amp; Play component):

```
php artisan vendor:publish --tag=registration-number-validator-assets --force

```

Usage
-----

[](#usage)

You have two ways to use this addon on your frontend:

### Option 1: Plug &amp; Play

[](#option-1-plug--play)

Use the included Antlers tag to render a complete, styled validation component. This includes the country selector, input field, validation logic, loading states, and error handling.

```
{{ registration_number_validator
    handle="billing_vat"
    placeholder="Enter Registration Number"
    :show_validate_button="true"
    :show_company_details_after_validation="true"
}}

```

#### Parameters

[](#parameters)

Parameter - Type - Default - Description

`handle` - String *Required* - Unique identifier. Generates inputs named `{handle}_country` and `{handle}_number`.

`placeholder` - String - `""` - Placeholder text for the input field.

`show_validate_button` - Boolean - `true` - Whether to display the "Validate" button next to the input.

`validate_button_text` - String - `"Validate"` - Text to display on the button.

`show_company_details_after_validation` - Boolean - `true` - If true, displays company name and address below the input on success.

### Option 2: Headless

[](#option-2-headless)

If you need complete control over the UI (e.g., custom layout, your own icons, or integration with a multi-step wizard), you can bypass the Vue component and interact directly with the Validation API.

I recommend using **Alpine.js** for a lightweight implementation.

#### The Endpoint

[](#the-endpoint)

- **URL:** `/!/registration_number_validator/validate`
- **Method:** `POST`
- **Headers:** `X-CSRF-TOKEN` (Required), `X-Requested-With: XMLHttpRequest`

#### Implementation Example (Alpine.js)

[](#implementation-example-alpinejs)

Copy this boilerplate into your Antlers template to get started:

```
{{-- Ensure Alpine.js is loaded:  --}}

            RO
            DE
            GB

            Validate
            Checking...

            ✓ Valid Registration

                Name:

                Address:

                    Registered:

function vatValidator() {
    return {
        country: 'RO',
        number: '',
        loading: false,
        error: null,
        result: null,

        async validate() {
            this.loading = true;
            this.error = null;
            this.result = null;

            try {
                // 1. Get CSRF Token from Statamic Meta Tag or Input
                // Ensure your layout has
                const token = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content');

                if (!token) {
                    this.error = "CSRF token missing. Please add the meta tag to your layout.";
                    this.loading = false;
                    return;
                }

                // 2. Perform Request
                const response = await fetch('/!/registration_number_validator/validate', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        'X-CSRF-TOKEN': token,
                        'X-Requested-With': 'XMLHttpRequest'
                    },
                    body: JSON.stringify({ country_code: this.country, number: this.number })
                });

                const data = await response.json();

                // 3. Handle Response
                if (data.valid) {
                    this.result = data.data;
                } else {
                    this.error = data.error || 'Invalid number';
                }
            } catch (e) {
                console.error(e);
                this.error = 'Validation failed. Please check connection.';
            } finally {
                this.loading = false;
            }
        }
    }
}

```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance72

Regular maintenance activity

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~52 days

Total

2

Last Release

159d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2ef94cb6df1688a6d1287ed31d12ecf056c8359fb5e837e65597b63b7f771c94?d=identicon)[alinandrei](/maintainers/alinandrei)

---

Top Contributors

[![alinescu16](https://avatars.githubusercontent.com/u/119789089?v=4)](https://github.com/alinescu16 "alinescu16 (19 commits)")

### Embed Badge

![Health badge](/badges/alinandrei-registration-number-validator/health.svg)

```
[![Health](https://phpackages.com/badges/alinandrei-registration-number-validator/health.svg)](https://phpackages.com/packages/alinandrei-registration-number-validator)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)[xemlock/htmlpurifier-html5

HTML5 support for HTML Purifier

1052.9M11](/packages/xemlock-htmlpurifier-html5)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
