How to validate your PESEL number in Orbeon Forms?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to validate your PESEL number in Orbeon Forms?

czajw
How to validate your PESEL number (more about here: https://en.wikipedia.org/wiki/PESEL) in Orbeon Forms?  PESEL is Polish acronym for „Universal Electronic System for Registration of the Population”. 

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/ffe97282-1934-4007-8d66-49550e565b26n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

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

Alessandro  Vernet
Administrator
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/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1606768888091-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

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

czajw
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;
}


--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/51f1a087-ecad-40eb-a7af-3160477687c9n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

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

czajw
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  

piątek, 15 stycznia 2021 o 22:40:45 UTC+1 Władysław Czaja napisał(a):
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;
}


--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/e682b0fb-73f1-41cb-b0e3-4915a5e97efan%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

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

Alessandro  Vernet
Administrator
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).

-Alex

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

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1611005536263-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet