Skip to content

[Feature] Add JsonRpcMethodNameValidator for reusable method name policy enforcement #27

@limehee

Description

@limehee

Problem statement

Method name policy checks (blank names, reserved namespace constraints such as rpc.*, and optional naming conventions) are currently spread across components. This increases duplication and risks inconsistent enforcement.

Proposed solution

Introduce JsonRpcMethodNameValidator in jsonrpc-core as a reusable policy utility:

  • validate blank/whitespace names
  • enforce reserved namespace policy (rpc.*)
  • optional extension point for additional naming constraints (pattern/length/custom predicates)

Then reuse the same validator in request validation and method registration paths.

Alternatives considered

  • Keep checks local in each component
  • Add utility methods without a dedicated validator abstraction

These alternatives still make policy evolution harder and can reintroduce drift.

JSON-RPC behavior impact

No default protocol behavior change (current reserved namespace rejection remains). This is mainly an internal consistency and reuse improvement.

Additional context

  • Keep default validator RFC-aligned and conservative.
  • Ensure error mapping remains unchanged for invalid method names.
  • Add tests proving consistent behavior across request validator and registration flows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: waiting-for-feedbackWaiting for additional information from reporter or stakeholders.type: featureNew feature specification and implementation.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions