Re: Re: cvs: pear /Validate/Validate ISPN.php

From: Date: Mon, 24 Jan 2005 09:21:20 +0000
Subject: Re: Re: cvs: pear /Validate/Validate ISPN.php
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-35688@lists.php.net to get a copy of this message
On Mon, 2005-01-24 at 09:04, Daniel Convissor wrote: > Hi Helgi: > > On Fri, Jan 21, 2005 at 07:30:33PM -0000, Helgi ormar orbjrnsson wrote: > > > + function process($data, $length, &$weights, $modulo = 10, $subtract = 0) > > I'm curious why someone should have to submit the $length. Before you > answer that, let me say two things. I haven't looked at the package or > the rest of the code. I'm just providing some input that I hope will be > helpful based on having written code (in Visual Basic) that processes and > validates Global Product Code (GPC) numbers (e.g. UPC, EAN, etc). Because X validation method takes in Y long input, ean14 takes 14 char length input and so on, the last char would be the control digit and it all depends on that one, so if it's accidentally submitted 15 digit long string everything goes amok, tho my self I haven't looked much into those things, but from what I read this is correct, plus I was just making a unified function and all those functions checked if the string was X length, so it was kinda logical :) > When scanning a bar code at a cash register, it can have various lengths. > It would be nice if there was a way to do something like this: > > <?php > if (!$id = validate($_POST['productid'])) { > echo 'no dice!'; > } > ?> Well you would have to tell it what kinda production validation it was, I'm not going to make some auto detect bug prone thing :-) I also think that the process thing would be suite people to wrap around to make their own custom functions like ean13 and them all, and hopefully submit to Validate via patch later. So if (!Validate_ISPN::someBarCodeFun($_POST['productid'])) { echo 'foo'; } Would work just fine. I kinda didn't intend for people to use process straight, rather jjust like I said, to make a wrapper function around process rather. > and the output would be false if it's bogus and a full 14 digit id (with 0 > padding on the left for shorter id's) that can be stored in a database. > > Also, I'm wondering, is there a method in the package that can convert the > short 8 digit UPC-E codes into full 14 digit codes? Of course, that's not > validation, but these numbers will come up in the context I'm discussing. Not that I know of, you could probably just add some digits at the front and as long as the result of the 13 chars with all the math magics become the same as the control digit then it should be just fine, but I really doubt that exists, since usually you're given some range I think to place on your products so you can't go around flipping between ean8 ean13 and ean14 ... Any who I think so, those docs I read didn't enlighten me on that issue at least. - Helgi

« previous php.pear.dev (#35688) next »