Re: How to validate your PESEL number in Orbeon Forms?

35 views
Skip to first unread message

Alessandro Vernet

unread,
Nov 30, 2020, 3:41:30 PM11/30/20
to orb...@googlegroups.com
Hi Władysław,

You can do this type of validation with XPath. For instance, I put below
some XPath I wrote in the past to validate the Swiss OASI Number. That one
is a 13-digit number, and the check in the last digit (like PESEL), and it
follows the EAN-13 regulations (not sure about PESEL). Here is the code fo
the Swiss OASI Number, an I hope this can help:

let
$digits := translate(., '.', ''),
$multiplied :=
for $pos in 1 to 12
return
let $multiplier := if ($pos mod 2 = 1) then 1 else 3
return xs:decimal(substring($digits, $pos, 1)) *
$multiplier,
$total := sum($multiplied),
$check := 10 - ($total mod 10),
$last-digit := xs:decimal(substring($digits, 13, 1))
return
$last-digit = $check

-Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

Władysław Czaja

unread,
Jan 15, 2021, 4:40:45 PM1/15/21
to Orbeon Forms
This is JavaScript code, could someone help to write it in XPath/XQuery?

function isValidPesel(pesel) {
let weight = [1, 3, 7, 9, 1, 3, 7, 9, 1, 3];
let sum = 0;
let controlNumber = parseInt(pesel.substring(10, 11));

for (let i = 0; i < weight.length; i++) {
sum += (parseInt(pesel.substring(i, i + 1)) * weight[i]);
}
sum = sum % 10;
return (10 - sum) % 10 === controlNumber;
}


Władysław Czaja

unread,
Jan 17, 2021, 1:31:42 PM1/17/21
to Orbeon Forms
More about PESEL here: https://en.wikipedia.org/wiki/PESEL) in Orbeon Forms?  PESEL is Polish acronym for „Universal Electronic System for Registration of the Population”.   

I'm just getting to know XPath / XQuery and thank you very much for any suggestions  

Alessandro Vernet

unread,
Jan 18, 2021, 4:32:18 PM1/18/21
to orb...@googlegroups.com
Hi Władysław,

I am not sure to have very specific recommendations to familiarize yourself
with XPath. If you already know a few other programming languages, maybe you
can start by going through a couple of XPath tutorials, and then just "jump
in" and start prototyping the code, based on the example I mentioned and
your own JavaScript code.

And if you would prefer to delegate this work, this is also something that
we can help with under a Dev Support plan (https://www.orbeon.com/services).
Reply all
Reply to author
Forward
0 new messages