vb.net - How to mask an integer field in database and also make sure it does not fail required validation in the application code -


1) want mask integer field (vsn number) in database.

2) there validation in code determines vsn valid or invalid.

3) masked vsn number should pass validation.

below validation code.

protected overrides function isvalid(byval vsn integer) boolean         dim vsn string = vsn.trim          '-- rules 1: lengh 9 include check digit         if not vsn.length = 9             return false         end if          '-- rules 2: digit must numeric         if not isnumeric(vsn)             return false         end if          '-- rules 3: weight factor , divide 11 remainder must 0         dim sumofweightvalue integer = cint(mid(vsn, 1, 1))*1         sumofweightvalue += cint(mid(vsn, 2, 1))*4         sumofweightvalue += cint(mid(vsn, 3, 1))*3         sumofweightvalue += cint(mid(vsn, 4, 1))*7         sumofweightvalue += cint(mid(vsn, 5, 1))*5         sumofweightvalue += cint(mid(vsn, 6, 1))*8         sumofweightvalue += cint(mid(vsn, 7, 1))*6         sumofweightvalue += cint(mid(vsn, 8, 1))*9         sumofweightvalue += cint(mid(vsn, 9, 1))*10          sumofweightvalue = sumofweightvalue mod 11          if sumofweightvalue <> 0             return false         else             return true         end if      end function 


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -