gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-anastasis] branch master updated: add support for INSEE numbers


From: gnunet
Subject: [taler-anastasis] branch master updated: add support for INSEE numbers
Date: Sun, 27 Feb 2022 16:22:15 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new 9cc9673  add support for INSEE numbers
9cc9673 is described below

commit 9cc967321656dd8d50231047c7366c82a9897e9c
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Feb 27 16:22:13 2022 +0100

    add support for INSEE numbers
---
 contrib/Makefile.am               |  1 +
 contrib/redux.countries.json      | 11 +++++++
 contrib/redux.fr.json             | 40 ++++++++++++++++++++++++
 src/reducer/Makefile.am           |  1 +
 src/reducer/validation_FR_INSEE.c | 66 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 119 insertions(+)

diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index 03bcab7..fdd16d2 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -56,6 +56,7 @@ pkgdata_DATA = \
   redux.de.json \
   redux.dk.json \
   redux.es.json \
+  redux.fr.json \
   redux.in.json \
   redux.it.json \
   redux.jp.json \
diff --git a/contrib/redux.countries.json b/contrib/redux.countries.json
index 44416e1..61dec37 100644
--- a/contrib/redux.countries.json
+++ b/contrib/redux.countries.json
@@ -83,6 +83,17 @@
                "currency": "EUR",
                "call_code" : "+44"
        },
+       {
+               "code" : "fr",
+               "name" : "France",
+               "continent" : "Europe",
+               "name_i18n" : {
+                       "de_DE": "Frankreich",
+                       "fr_FR": "La France"
+               },
+               "currency": "EUR",
+               "call_code" : "+33"
+       },
        {
                "code" : "in",
                "name" : "India",
diff --git a/contrib/redux.fr.json b/contrib/redux.fr.json
new file mode 100644
index 0000000..1b57210
--- /dev/null
+++ b/contrib/redux.fr.json
@@ -0,0 +1,40 @@
+{
+    "license": "GPLv3+",
+    "SPDX-License-Identifier": "GPL3.0-or-later",
+    "required_attributes": [
+       {
+           "type": "string",
+           "name": "full_name",
+           "label": "Full name",
+           "widget": "anastasis_gtk_ia_full_name",
+            "uuid" : "9e8f463f-575f-42cb-85f3-759559997331"
+       },
+       {
+           "type": "date",
+           "name": "birthdate",
+           "label": "Birthdate",
+           "widget": "anastasis_gtk_ia_birthdate",
+            "uuid" : "83d655c7-bdb6-484d-904e-80c1058c8854"
+       },
+       {
+           "type": "string",
+           "name": "birthplace",
+           "label": "Birthplace",
+           "widget": "anastasis_gtk_ia_birthplace",
+            "uuid" : "4c822e8e-89c6-11eb-95c4-8b077ad8489f"
+       },
+       {
+           "type": "string",
+           "name": "social_security_number",
+           "label": "Code Insee",
+           "label_i18n":{
+               "fr_FR": "Code Insee",
+               "en": "INSEE code"
+           },
+           "widget": "anastasis_gtk_ia_insee_fr",
+            "uuid": "2f36a81c-3f6d-41f3-97ee-9c885bc41873",
+           "validation-regex": "^[0-9]{15}$",
+           "validation-logic": "FR_INSEE_check"
+       }
+    ]
+}
diff --git a/src/reducer/Makefile.am b/src/reducer/Makefile.am
index bfdb521..6dad659 100644
--- a/src/reducer/Makefile.am
+++ b/src/reducer/Makefile.am
@@ -24,6 +24,7 @@ libanastasisredux_la_SOURCES = \
   validation_DE_SVN.c \
   validation_DE_TIN.c \
   validation_ES_DNI.c \
+  validation_FR_INSEE.c \
   validation_IN_AADHAR.c \
   validation_IT_CF.c \
   validation_NL_BSN.c \
diff --git a/src/reducer/validation_FR_INSEE.c 
b/src/reducer/validation_FR_INSEE.c
new file mode 100644
index 0000000..19d81fd
--- /dev/null
+++ b/src/reducer/validation_FR_INSEE.c
@@ -0,0 +1,66 @@
+/*
+  This file is part of Anastasis
+  Copyright (C) 2022 Anastasis SARL
+
+  Anastasis is free software; you can redistribute it and/or modify it under 
the
+  terms of the GNU 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 General Public License for more details.
+
+  You should have received a copy of the GNU General Public License along with
+  Anastasis; see the file COPYING.GPL.  If not, see 
<http://www.gnu.org/licenses/>
+*/
+/**
+ * @file reducer/validation_FR_INSEE.c
+ * @brief Validation for French INSEE Numbers
+ * @author Christian Grothoff
+ */
+#include <string.h>
+#include <stdbool.h>
+#include <stdio.h>
+
+
+/**
+ * Function to validate a French INSEE number.
+ *
+ * See https://en.wikipedia.org/wiki/INSEE_code
+ *
+ * Note that we do not implement checks on the month
+ * and also allow non-binary prefixes.
+ *
+ * @param insee_number social security number to validate (input)
+ * @return true if validation passed, else false
+ */
+bool
+FR_INSEE_check (const char *insee_number)
+{
+  char pfx[14];
+  unsigned long long num;
+  unsigned int cc;
+  char dum;
+
+  if (strlen (insee_number) != 15)
+    return false;
+  memcpy (pfx,
+          insee_number,
+          13);
+  pfx[13] = '\0';
+  if (1 !=
+      sscanf (pfx,
+              "%llu%c",
+              &num,
+              &dum))
+    return false;
+  if (1 !=
+      sscanf (&insee_number[13],
+              "%u%c",
+              &cc,
+              &dum))
+    return false;
+  if (97 - cc != num % 97)
+    return false;
+  return true;
+}

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]