Weave Code
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

Assert Laravel Package

simplesamlphp/assert

Fork of webmozart/assert that lets every assertion throw your chosen exception (or a default AssertionFailedException) instead of always InvalidArgumentException. Adds a few custom assertions aimed at XML/SAML2 use cases.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Enhanced Data Validation & Integrity: Strengthen validation for enum-based fields (e.g., status flags, predefined categories) in APIs, forms, and internal services, reducing edge-case bugs and improving data consistency. The new enum support aligns with modern PHP 8+ features, enabling stricter type safety.
  • Developer Productivity: Eliminate repetitive manual checks for enums (e.g., if (!in_array($status, ['active', 'inactive']))) by leveraging assert::isEnum($value, Status::class). Reduces cognitive load and boilerplate for teams adopting PHP 8.1+ enums.
  • Security & Compliance: Mitigate risks from malformed input (e.g., newline characters in regex patterns) with stricter validation rules, critical for financial, healthcare, or regulatory-sensitive applications.
  • Roadmap for Modern PHP Features: Future-proof validation logic by supporting enums and PHP 8+ types, reducing refactoring costs when migrating legacy codebases.
  • Build vs. Buy: Avoid custom enum validation logic or third-party libraries; this package provides a Laravel-native solution with minimal overhead.

When to Consider This Package

  • Adopt if:

    • Your Laravel/PHP codebase uses PHP 8.1+ enums and needs validation for enum fields (e.g., Status::class, Role::class).
    • You require stricter regex validation (e.g., rejecting newlines in user input, passwords, or API payloads) to prevent injection or malformed data.
    • Your team is migrating to PHP 8+ and wants to standardize validation for modern types (enums, attributes, etc.).
    • You need fine-grained control over validation beyond Laravel’s Validator (e.g., nested arrays, callbacks, or custom types).
    • Your project prioritizes consistent error messages and debugging for validation failures in microservices or monoliths.
  • Look elsewhere if:

    • You’re not using PHP 8.1+ and enums are irrelevant to your stack (this feature adds minimal value).
    • Your validation needs are form-heavy (use Laravel’s FormRequest or Validator facade instead).
    • You require complex business rules (e.g., multi-step workflows) better handled by a dedicated rules engine (e.g., Spatie’s Laravel Rules).
    • Your team lacks PHP/Laravel expertise to integrate third-party packages or lacks time for adoption.
    • You’re constrained by license compatibility (LGPL-2.1 may require review for proprietary projects).

How to Pitch It (Stakeholders)

For Executives: "This updated package now supports PHP 8.1+ enums and stricter regex validation, giving us tighter control over data integrity in our Laravel services. For example, we can now validate that a user’s Status field is always one of the allowed enum values—without manual checks—while also blocking risky input like newlines in sensitive fields. This reduces bugs, improves security, and future-proofs our codebase for modern PHP features. It’s a lightweight, open-source solution that pays dividends in developer productivity and reliability."

For Engineering: *"We’re upgrading to v1.5.0 of simplesamlphp/assert to leverage two key improvements:

  1. Enum support: Replace manual enum checks (e.g., if (!in_array($status, [...]))) with clean assertions:
    assert::isEnum($user->status, Status::class);
    
  2. Stricter regex validation: Automatically reject newlines in patterns (e.g., passwords, API keys) to prevent edge-case vulnerabilities. Impact:
  • Faster development: Less boilerplate for enum/validation logic.
  • Fewer bugs: Catches invalid enums or malformed input early.
  • Modern PHP ready: Aligns with PHP 8+ features without refactoring overhead. Effort: Low—just update the package and replace a few manual checks. Prioritize for new features using enums or regex-heavy validation."*
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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity