Skip to content

Validate LightningConfig (sendable range, callback URL) #33

Description

@Chemaclass

Context

LightningConfig accepts values without validation. A misconfiguration (e.g. min > max sendable range, empty/invalid callback URL) surfaces late as confusing runtime behavior rather than a clear config-time error.

  • src/Config/LightningConfig.php — fluent setters; setSendableRange(int $min, int $max), setCallbackUrl(string), setDomain(string).
  • src/Shared/Value/SendableRange.phpwithMinMax(int $min, int $max) does no ordering check.

Goal

Fail fast with clear messages on invalid configuration.

Scope / Tasks

  • Validate the sendable range: min >= 1, max >= min (LUD-06: minSendable cannot be less than 1 or greater than maxSendable). Throw a clear exception otherwise — decide whether the guard lives in SendableRange::withMinMax() (preferred, single source of truth) or the setter.
  • Validate callbackUrl is a non-empty, parseable URL (or documented base).
  • Keep setDomain()'s scheme-stripping behavior; reject clearly empty/invalid domains.
  • Unit tests for each invalid case (assert exception + message) and that valid configs are unaffected.

Implementation notes

  • Prefer runtime validation with clear messages over silent coercion.
  • Match existing exception style (RuntimeException with an interpolated, specific message), consistent with LightningConfig::addBackendsFile() and BackendType::fromString().
  • Don't over-validate: only guard values that cause real downstream breakage.

Acceptance criteria

  • min > max, min < 1, empty/invalid callback URL each throw a specific, actionable exception.
  • Existing valid-config tests still pass.
  • composer test-all green.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions