- What is mattkingshott/axiom used for?
- Axiom is a Laravel package for defining business rules as reusable, testable classes. It provides a fluent API for validating models against domain invariants and integrates with Laravel validation and testing tools. Use it to keep complex validation logic out of controllers and form requests.
- How do I install Axiom in a Laravel application?
- Install it with Composer using composer require mattkingshott/axiom. Confirm the package's service provider registration and any publishable configuration or language files in the repository documentation. Because the provided excerpt is empty, check the README and composer.json for exact setup steps.
- Which Laravel and PHP versions does Axiom support?
- The provided context does not list exact Laravel or PHP version constraints. Check the package's composer.json and CI matrix on GitHub for the supported Laravel and PHP versions. Verify those constraints against your application before upgrading, especially when adopting a patch release.
- How do I create a custom validation rule with Axiom?
- Axiom is designed around defining business rules as reusable, testable classes with a fluent API for model and domain-invariant checks. Follow the package README for the base class or contract to implement, then add tests for valid and invalid cases. Keep rule classes focused so they can be reused across form requests and service-layer validation.
- Can I use Axiom rules inside Laravel Form Requests?
- Axiom integrates with Laravel's validation and testing tools, so its rules can likely be consumed by form requests or custom validators. Confirm the exact rule class names and registration requirements in the package documentation. If you already have Vietnamese ID validation, compare behavior before replacing it.
- Does Axiom include a Vietnamese citizen ID validation rule?
- The assessment context references a Vietnamese citizen rule added in Axiom v3.2.1. The exact behavior is not specified, but it likely targets Vietnamese citizen ID formats such as CCCD or CMND. Inspect the rule source and fixtures to confirm checksum, length, and historical format handling.
- How do I test Axiom validation rules?
- Write unit tests for each rule class with representative valid and invalid fixtures, including edge cases. For Vietnamese citizen identifiers, include historical and current formats plus malformed values. Axiom's integration with Laravel testing tools should let you assert validation passes and fails through normal validator assertions.
- Are Axiom validation error messages translatable?
- The provided context does not confirm whether Axiom ships translations for every rule. Check whether the package includes language files or whether your application must publish and translate messages. For user-facing forms, provide clear localized guidance on accepted Vietnamese citizen ID formats.
- Is the Vietnamese citizen rule opt-in or default behavior in Axiom?
- The assessment flags this as a key question: confirm whether the rule is opt-in or becomes part of default validation behavior. If it is purely additive and opt-in, adoption risk is low. If it changes existing validation, review the diff and test backward compatibility before upgrading.
- What are the production risks of using Axiom for validation?
- The main risks are false negatives that block legitimate users and false positives that admit invalid identifiers. Locale-specific rules can become outdated, so establish ownership for package upgrades and periodic rule-accuracy reviews. Validation runtime impact is likely negligible, but support volume may rise if error messages or accepted formats are unclear.