I'm doing a requires statement so the id number matches a prescribed
format, encrypt it, and then store it in the database (if it isn't a
duplicate number)
db.card.id_number.requires=[eval(db.agency[int(request.vars.id_number)].regex),CRYPT(),IS_NOT_IN_DB(db,'card.id_number')
Do you use eval() and strings for validation? I've tested eval() in a
Shell for validation like:
eval(db.agency[id].regex)('')
where regex column is something like: "IS_MATCH('^\\d{3}-\\d{4}-\\d{4}-\
\d{1}?$')" or Null, and it works! The idea, is that every record in the
administrative table comes with the regex needed to validate the id
number.
But when I try it in a requires statement, it complains that
request.vars.id_number is not valid, but I couldn't place an expression
inside eval(). I already have a CRUD form that uses a validation routine
called by onaccept, but I'm wondering if I could replace it instead with
just a requires statement.
I use it like this in my custom validation:
if (db.agency[int(form.vars.issuer)].regex and\
eval(db.agency[int(form.vars.issuer)].regex)(form.vars.id_number)[1]!=
None):
form.errors.id_number='Enter id number exactly as shown in your card.'
Looking forward to hear your suggestions. TIA.
/r
Nik