Skip to main content

validate_insert_body

Function validate_insert_body 

Source
pub fn validate_insert_body(value: Value) -> Result<InsertValues, Error>
Expand description

Validates and converts a JSON value into InsertValues

Supports both single object and array of objects.

§Arguments

  • value - Parsed JSON value to validate

§Examples

use postgrest_parser::parser::{parse_json_body, validate_insert_body};

// Single row
let body = r#"{"name": "Alice", "age": 30}"#;
let value = parse_json_body(body).unwrap();
let insert_values = validate_insert_body(value).unwrap();

// Multiple rows
let body = r#"[{"name": "Alice"}, {"name": "Bob"}]"#;
let value = parse_json_body(body).unwrap();
let insert_values = validate_insert_body(value).unwrap();