Class DatevValidator

java.lang.Object
io.github.mrtyldr.datev.validation.DatevValidator
All Implemented Interfaces:
BiConsumer<Integer,List<String>>

public final class DatevValidator extends Object implements BiConsumer<Integer,List<String>>
Immutable, implementation-neutral DATEV Buchungsstapel row validator.

This class is a thin adapter: it binds the shared validation core in datev-exporter-core to the BiConsumer<Integer, List<String>> callback that both lean DatevFile factories accept, without linking this artifact to either exporter implementation.

The validator receives logical, unquoted values. CSV parsing and escaping remain the responsibility of the selected exporter.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Builder for an immutable validator.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    accept(Integer formatVersion, List<String> values)
    Implements the standard callback accepted directly by both lean exporters.
    Starts an immutable validator builder.
    io.github.mrtyldr.datev.core.DatevValidationContext
    Returns metadata-dependent constraints.
    boolean
    equals(Object other)
    Compares the configured mode and context.
    Creates a field-level validator without required or pair checks.
    int
    Returns a hash code consistent with equals(Object).
    io.github.mrtyldr.datev.core.DatevValidationMode
    Returns the validation depth.
    Creates a strict validator without metadata-dependent constraints.
    Returns a diagnostic description of this validator's configuration.
    List<io.github.mrtyldr.datev.core.DatevValidationError>
    validate(int formatVersion, List<String> values)
    Validates by numeric schema version, matching the lean exporters' dependency-free callback.
    List<io.github.mrtyldr.datev.core.DatevValidationError>
    validate(io.github.mrtyldr.datev.core.DatevSchema schema, List<String> values)
    Validates a complete fixed-schema row and returns every error in field order.
    void
    validateOrThrow(int formatVersion, List<String> values)
    Validates by numeric schema version and throws one aggregate exception on failure.
    void
    validateOrThrow(io.github.mrtyldr.datev.core.DatevSchema schema, List<String> values)
    Validates and throws one aggregate exception when any rule fails.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.util.function.BiConsumer

    andThen
  • Method Details

    • equals

      public boolean equals(Object other)
      Compares the configured mode and context.
      Overrides:
      equals in class Object
      Parameters:
      other - the object to compare with
      Returns:
      true if the other object is a validator with equal configuration
    • hashCode

      public int hashCode()
      Returns a hash code consistent with equals(Object).
      Overrides:
      hashCode in class Object
      Returns:
      the hash code
    • toString

      public String toString()
      Returns a diagnostic description of this validator's configuration.
      Overrides:
      toString in class Object
      Returns:
      the mode and context
    • strict

      public static DatevValidator strict()
      Creates a strict validator without metadata-dependent constraints.
      Returns:
      strict validator
    • fieldLevel

      public static DatevValidator fieldLevel()
      Creates a field-level validator without required or pair checks.
      Returns:
      field-level validator
    • builder

      public static DatevValidator.Builder builder()
      Starts an immutable validator builder.
      Returns:
      new builder
    • mode

      public io.github.mrtyldr.datev.core.DatevValidationMode mode()
      Returns the validation depth.
      Returns:
      mode
    • context

      public io.github.mrtyldr.datev.core.DatevValidationContext context()
      Returns metadata-dependent constraints.
      Returns:
      immutable context
    • validate

      public List<io.github.mrtyldr.datev.core.DatevValidationError> validate(io.github.mrtyldr.datev.core.DatevSchema schema, List<String> values)
      Validates a complete fixed-schema row and returns every error in field order.
      Parameters:
      schema - fixed DATEV schema
      values - logical, unquoted cell values
      Returns:
      immutable validation errors
      Throws:
      IllegalArgumentException - when row width differs from the selected schema
    • validate

      public List<io.github.mrtyldr.datev.core.DatevValidationError> validate(int formatVersion, List<String> values)
      Validates by numeric schema version, matching the lean exporters' dependency-free callback.
      Parameters:
      formatVersion - DATEV Buchungsstapel format version 12 or 13
      values - logical, unquoted cell values
      Returns:
      immutable validation errors
    • validateOrThrow

      public void validateOrThrow(io.github.mrtyldr.datev.core.DatevSchema schema, List<String> values)
      Validates and throws one aggregate exception when any rule fails.
      Parameters:
      schema - fixed DATEV schema
      values - logical, unquoted cell values
      Throws:
      io.github.mrtyldr.datev.core.DatevValidationException - when validation fails
    • validateOrThrow

      public void validateOrThrow(int formatVersion, List<String> values)
      Validates by numeric schema version and throws one aggregate exception on failure.
      Parameters:
      formatVersion - DATEV Buchungsstapel format version 12 or 13
      values - logical, unquoted cell values
    • accept

      public void accept(Integer formatVersion, List<String> values)
      Implements the standard callback accepted directly by both lean exporters.
      Specified by:
      accept in interface BiConsumer<Integer,List<String>>
      Parameters:
      formatVersion - DATEV Buchungsstapel format version 12 or 13
      values - immutable logical row values