Generate and validate 'CouponCode' strings
A 'Coupon Code' is made up of letters and numbers grouped into 4 character
'parts'. For example, a 3-part code might look like this:
Coupon Codes are random codes which are easy for the recipient to type
accurately into a web form. An example application might be to print a code
on a letter to a customer who would then enter the code as part of the
registration process for web access to their account.
Features of the codes that make them well suited to manual transcription:
* The codes are not case sensitive.
* Not all letters and numbers are used, so if a person enters the letter 'O'
we can automatically correct it to the digit '0' (similarly for I => 1, S
=> 5, Z => 2).
* The 4th character of each part is a checkdigit, so client-side scripting
can be used to highlight parts which have been mis-typed, before the code
is even submitted to the application's back-end validation.
* The checkdigit algorithm takes into account the position of the part being
keyed. So for example '1K7Q' might be valid in the first part but not in
the second so if a user typed the parts in the wrong boxes then their error
could be highlighted.
* The code generation algorithm avoids 'undesirable' codes. For example any
code in which transposed characters happen to result in a valid checkdigit
will be skipped. Any generated part which happens to spell an
'inappropriate' 4-letter word (e.g.: 'P00P') will also be skipped.
of the validator function, in the form of a jQuery plugin. You can include
this in your web application to do client-side validation and highlighting
that the code is 'well-formed' (i.e.: each part has a valid checkdigit).
Checking whether the code is in fact 'valid' is left up to your application
and would typically involve looking for the code in a database. If you use
highlighting of checksum errors but remove the green highlighting which
might imply the code was correct.
Для openSUSE Leap 15.4 нет официального пакета