-module(toon_codec@decode@validation). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/toon_codec/decode/validation.gleam"). -export([validate_count/3, validate_row_width/3, validate_indentation/3]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC( " Validation functions for strict mode decoding.\n" "\n" " This module provides functions to validate counts, indentation,\n" " and other structural requirements in strict mode.\n" " Validate that actual count matches expected count.\n" "\n" " Used in strict mode to ensure array lengths match declarations.\n" " Validate row width in tabular arrays.\n" " Validate that indentation is a multiple of indent_size.\n" ). -file("src/toon_codec/decode/validation.gleam", 16). -spec validate_count(integer(), integer(), binary()) -> {ok, nil} | {error, toon_codec@error:toon_error()}. validate_count(Expected, Actual, Context) -> case Expected =:= Actual of true -> {ok, nil}; false -> {error, toon_codec@error:count_mismatch(Expected, Actual, Context)} end. -file("src/toon_codec/decode/validation.gleam", 27). -spec validate_row_width(integer(), integer(), integer()) -> {ok, nil} | {error, toon_codec@error:toon_error()}. validate_row_width(Expected, Actual, Row_number) -> case Expected =:= Actual of true -> {ok, nil}; false -> {error, toon_codec@error:validation_error( <<<<<<<<<<"Row "/utf8, (erlang:integer_to_binary(Row_number))/binary>>/binary, ": expected "/utf8>>/binary, (erlang:integer_to_binary(Expected))/binary>>/binary, " values, got "/utf8>>/binary, (erlang:integer_to_binary(Actual))/binary>> )} end. -file("src/toon_codec/decode/validation.gleam", 48). -spec validate_indentation(integer(), integer(), integer()) -> {ok, nil} | {error, toon_codec@error:toon_error()}. validate_indentation(Indent, Indent_size, Line) -> case case Indent_size of 0 -> 0; Gleam@denominator -> Indent rem Gleam@denominator end of 0 -> {ok, nil}; _ -> {error, toon_codec@error:indentation_error( <<<<"Indentation must be a multiple of "/utf8, (erlang:integer_to_binary(Indent_size))/binary>>/binary, " spaces"/utf8>>, Line )} end.