caffeine_lang/common/validations

Values

pub fn check_collection_key_overshadowing(
  reference_collection: dict.Dict(String, a),
  referrer_collection: dict.Dict(String, b),
  error_msg: String,
) -> Result(Bool, String)

Checks if any keys in the referrer collection overlap with the reference collection. Returns an error with the overlapping keys if overshadowing is detected.

pub fn inputs_validator(
  params params: dict.Dict(String, accepted_types.AcceptedTypes),
  inputs inputs: dict.Dict(String, dynamic.Dynamic),
) -> Result(Bool, String)

Validates that inputs match the expected params in both keys and types. Returns an error if there are missing keys, extra keys, or type mismatches. Note: Optional and Defaulted params are allowed to be omitted from inputs.

pub fn validate_inputs_for_collection(
  input_param_collections: List(#(a, b)),
  get_inputs: fn(a) -> dict.Dict(String, dynamic.Dynamic),
  get_params: fn(b) -> dict.Dict(
    String,
    accepted_types.AcceptedTypes,
  ),
) -> Result(Bool, errors.CompilationError)

Validates inputs against params for a collection of paired items. Aggregates all validation errors across the collection into a single result.

pub fn validate_relevant_uniqueness(
  things_to_validate_uniqueness_for: List(a),
  fetch_property: fn(a) -> String,
  thing_label: String,
) -> Result(Bool, errors.CompilationError)

Validates that all items in a list have unique values for a given property. Returns a ParserDuplicateError listing any duplicate values found.

pub fn validate_value_type(
  value: dynamic.Dynamic,
  expected_type: accepted_types.AcceptedTypes,
  type_key_identifier: String,
) -> Result(dynamic.Dynamic, errors.CompilationError)

Validates that a dynamic value matches the expected AcceptedType. Returns the original value if valid, or a CompilationError describing the type mismatch.

Search Document