Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Symfony Validation

Symfony Validation Laravel Package

phpviet/symfony-validation

Adds Vietnamese validation rules to Symfony Validator, with constraints for phone numbers, citizen ID cards, tax codes, and other local formats. Drop-in attributes make validating Vietnamese user data simple and consistent.

View on GitHub
Deep Wiki
Context7

:boom: Bundle hổ trợ tích hợp validation dành riêng cho Symfony framework.

Frequently asked questions about Symfony Validation
How do I install phpviet/symfony-validation?
Install it with Composer using composer require phpviet/symfony-validation. Then make sure your project's autoloading is updated; Symfony Flex projects typically need no extra bootstrap for constraint classes. Check the repository README for any service or configuration steps tied to your Symfony version.
Can I use phpviet/symfony-validation in Laravel?
No, this package targets Symfony's Validator component, not Laravel's native validator. Laravel applications should use the PHPViet Laravel validation package or explicitly wrap the Symfony validator. Mixing the two validation stacks in one app usually adds unnecessary complexity.
Which Vietnamese data formats does this package validate?
The package provides constraints for Vietnamese phone numbers, citizen identity cards, and tax codes. These cover common local formats used in Vietnamese user, billing, and KYC data. For domain-specific rules beyond format checks, combine them with Symfony's built-in constraints.
How do I apply Vietnamese validation constraints to an entity or DTO?
Import the package's constraint classes and add them as PHP attributes on the properties you want to validate. The same constraints can be used in annotation style for projects that still rely on docblock annotations. Symfony's Validator reads the metadata and returns violations when a value does not match the Vietnamese format.
Does phpviet/symfony-validation work with Symfony Forms?
Yes. You can attach the constraints to the data class bound to your form, or add them directly to form fields where supported. When the form is submitted, Symfony's Form component runs the Validator and maps violations back to the correct fields.
Which Symfony versions are supported by phpviet/symfony-validation?
The exact supported versions are defined in the package's composer.json and release notes. Attribute-based constraint usage requires Symfony 5.2 or later, while annotation support suits older projects. Always check the repository before upgrading major Symfony versions.
Do I need to register services or a bundle for phpviet/symfony-validation?
In most setups, no bundle or service registration is required because constraints are metadata classes consumed by Symfony's Validator. If a constraint relies on a service-backed validator, register that validator in services.yaml and tag it with validator.constraint_validator. Symfony Flex auto-configuration may handle this for you.
How can I test these Vietnamese validation constraints with PHPUnit?
Create a validator with Validation::createValidatorBuilder()->enableAttributeMapping()->getValidator(), then validate a DTO or entity and assert the expected violation count and messages. For integration tests, fetch the validator service from the Symfony container in KernelTestCase. Keep phone numbers and IDs in fixtures so tests cover valid, invalid, and edge-case formats.
Can I customize the error messages for Vietnamese validation failures?
Most Symfony constraints accept a message option, so you can override the default text directly in the attribute or annotation. For multilingual apps, use Symfony's translator and provide translations for the message keys. This lets you return clear Vietnamese or English error messages without changing the validation logic.
What are alternatives to phpviet/symfony-validation?
You can use Symfony's Regex constraint with your own Vietnamese phone, citizen ID, and tax code patterns. Other options include general-purpose validation libraries or writing custom Constraint and ConstraintValidator classes. This package is convenient when you want maintained, reusable rules that plug directly into Symfony's metadata system.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core