Skip to main content

validate_app_data_doc

Function validate_app_data_doc 

Source
pub fn validate_app_data_doc(doc: &AppDataDoc) -> ValidationResult
Expand description

Validate an AppDataDoc against all CoW Protocol app-data rules.

Runs up to three independent checks and merges their results into a single ValidationResult:

  1. Version checkversion must be non-empty and parse as semver x.y.z.
  2. Business-rule constraintsappCode length, hook address format, partnerFee basis-point caps, and similar field-level rules enforced by the private validation helper module.
  3. JSON Schema validation(only when the schema-validation feature is enabled; on by default for native targets, off by default on wasm) the serialised document is checked against the bundled upstream schema via the schema module, catching structural drift that the hand-written business rules do not cover (missing required fields, unknown properties, regex violations, anyOf variants, …).

Returns a ValidationResult that lists every violation found. An empty ValidationResult::typed_errors list means the document is fully valid.

§Example

use cow_app_data::{AppDataDoc, validate_app_data_doc};

let doc = AppDataDoc::new("CoW Swap");
let result = validate_app_data_doc(&doc);
assert!(result.is_valid());
assert!(!result.has_errors());