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

Scalar Values Laravel Package

ecommit/scalar-values

Tiny PHP utility to validate and filter arrays of scalar values. Check whether an array contains only scalars (string/int/float/bool/null), or remove non-scalar items at the root level and return the cleaned array.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Data Validation & Sanitization: Enables strict validation of input arrays (e.g., API payloads, form submissions) to ensure only scalar values (strings, integers, floats, booleans) are processed, reducing edge-case bugs in nested data structures.
  • Performance Optimization: Eliminates unnecessary nested arrays/objects early in the pipeline (via filterScalarValues), reducing memory overhead and improving processing speed for large datasets.
  • Build vs. Buy: Avoids reinventing wheel for scalar validation logic, saving dev time while adhering to MIT license (no legal/licensing risks).
  • Use Cases:
    • APIs: Validate incoming requests (e.g., reject malformed JSON with nested objects where scalars are expected).
    • Data Migration: Cleanse legacy datasets before transformation.
    • Configuration Parsing: Ensure config arrays (e.g., YAML/JSON) meet strict scalar-only requirements.
    • Testing: Assert data integrity in unit/integration tests (e.g., mock responses or inputs).

When to Consider This Package

  • Adopt if:

    • Your PHP/Laravel app frequently processes user input or external data requiring strict scalar validation (e.g., APIs, forms, configs).
    • You need a lightweight, composable utility (no dependencies, MIT license) to filter/sanitize arrays without deep recursion or complex logic.
    • Your team prioritizes defensive programming (e.g., rejecting invalid data early to fail fast).
    • You’re using Laravel and want to integrate this into request validation pipelines (e.g., FormRequest or middleware).
  • Look elsewhere if:

    • You need deep recursion (e.g., validate scalars in nested arrays of arbitrary depth)—this package only checks root-level scalars.
    • You require type-specific validation (e.g., "only strings of length > 5")—consider Respect/Validation or Laravel’s built-in validators.
    • Your project uses non-PHP backends (e.g., Node.js, Python) or needs cross-language solutions.
    • You’re constrained by package popularity/maturity (0 stars, minimal adoption; evaluate risk for long-term maintenance).

How to Pitch It (Stakeholders)

For Executives: "This tiny, MIT-licensed PHP package lets us automatically validate and clean user/input data to ensure only simple values (strings, numbers, booleans) are processed—no nested objects or arrays. It’s like a ‘scalar-only’ gatekeeper for our APIs and data pipelines. By catching invalid data early, we reduce bugs, improve performance, and save dev time that would otherwise go into custom validation logic. Zero dependencies, zero cost, and it integrates seamlessly with Laravel."

For Engineers: *"Need to ensure an array only contains scalars (no objects/arrays)?

  • Validate: ScalarValues::containsOnlyScalarValues($array) → bool.
  • Sanitize: ScalarValues::filterScalarValues($array) → strips non-scalars in one pass. Lightweight, no bloat, and works great in Laravel’s request lifecycle (e.g., middleware or FormRequest validation). Perfect for APIs, configs, or data migration scripts where you want to fail fast on malformed input."*
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.
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log
hsluv/hsluv
seampact/codegen
seampact/hooks
seampact/ir
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table