/*
  This file is part of Anastasis
  Copyright (C) 2026 Anastasis SARL

  Anastasis is free software; you can redistribute it and/or modify it under the
  terms of the GNU Lesser General Public License as published by the Free Software
  Foundation; either version 3, or (at your option) any later version.

  Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public License along with
  Anastasis; see the file COPYING.LGPL.  If not, see <http://www.gnu.org/licenses/>
*/
/**
 * @file reducer/validation.h
 * @brief lookup of the national identity number validation functions
 * @author Christian Grothoff
 *
 * The `validation-logic` name of an attribute comes from the reducer state,
 * which is attacker-influenceable.  It must therefore never be used to look up
 * a symbol at run time; the name is resolved against the fixed table in
 * validation.c instead, and an unknown name is a validation failure.
 */
#ifndef ANASTASIS_VALIDATION_H
#define ANASTASIS_VALIDATION_H

#include <stdbool.h>

/**
 * Signature of the per-country identity number check functions.
 *
 * @param number the identity number entered by the user
 * @return true if @a number is well-formed
 */
typedef bool
(*ANASTASIS_ValidationLogic)(const char *number);


/**
 * Resolve @a name to the validation function implementing it.
 *
 * @param name value of the "validation-logic" field, must not be NULL
 * @return NULL if @a name is not a known validation function
 */
ANASTASIS_ValidationLogic
ANASTASIS_REDUX_validation_lookup_ (const char *name);


bool
BE_NRN_check (const char *nrn_number);

bool
CH_AHV_check (const char *ahv_number);

bool
CZ_BN_check (const char *b_number);

bool
DE_SVN_check (const char *ssn_number);

bool
DE_TIN_check (const char *tin_number);

bool
ES_DNI_check (const char *dni_number);

bool
FR_INSEE_check (const char *insee_number);

bool
IN_AADHAR_check (const char *aadhar_number);

bool
IT_CF_check (const char *cf_number);

bool
NL_BSN_check (const char *bsn_number);

bool
XX_SQUARE_check (const char *sq_number);

bool
XY_PRIME_check (const char *pr_number);

#endif
