Validates string lengths, formats, and trust levels for incoming API payloads. Reuse to protect backend services from storage abuse and invalid inputs.
// Source: https://github.com/backbay-labs/clawdstrike | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works // Provided via justclaw.it.com; keep this notice with the code. //! Input length validation helpers for API route handlers. //! //! All string fields accepted from clients must be bounded to prevent storage //! abuse. These helpers return `ApiError::BadRequest` with a descriptive //! message on validation failure. use crate::error::ApiError; /// Maximum byte length for general string fields (name, external_id, policy_name, etc.). const MAX_STRING_LEN: usize = 255; /// Maximum byte length for Ed25519 public key hex strings. /// Ed25519 hex-encoded public keys are 64 characters; we allow some headroom. const MAX_PUBLIC_KEY_LEN: usize = 128; ... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key