This topic is locked

Add/Edit Custom 'validate as' functions?

3/29/2007 6:33:33 AM
PHPRunner General questions
M
Martijn author

Hello,
I am new to phprunner atm I am looking at the trail version. I have to say that i really like what i see so far.

I started a test website and looked at the "validate as" properties and i couldn't find the ability to add custom validation checks.
Is it possible to add/edit custom validation functions?
I am dutch (that explains my english <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=4911&image=1&table=forumtopics' class='bbc_emoticon' alt=';)' />) and we need other types of validations. An example a phone number here is: 020-5412111 and I want to have the ability to add some other checks like banknumber validation.
I hope somebody can help me with this question.
Thanks

Martijn

V
Vladimir 3/29/2007

Martijn,
you should add/edit custom validation functions in the Before record added/updated events on Events tab.

M
Martijn author 3/29/2007

Martijn,

you should add/edit custom validation functions in the Before record added/updated events on Events tab.


I will give it a try. So I guess it's not that easy to add custom "validate as" functions in the interface of the properties. Maybe a nice feature in the future for easier code reuse <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=16595&image=1&table=forumreplies' class='bbc_emoticon' alt=';)' />
Still a nice program.
Tnx Vladimir

M
Martijn author 3/29/2007

I'm no skilled php programmer so I try to do it with some basic functions. Am I on the right track? Please comment if you have some better idea. Maybe with some example code?
--8<-------------------------------------------------------

$invalid = 0;

foreach($values as $field=>$value) {

switch ($field) {

case "Bank":

echo $field." : ".$value."\r\n";

$length = strlen($value);

$total = 0;

$count = 9;

if ($length != 9){

$invalid++;echo "FOUT";

} else {

for($i=0;$i<$length;$i++){

$number_temp = substr($value, $i, 1);

$total = $total + $number_temp * $count;

$count--;

}

if ($total % 11 != 0)

{ $invalid++;echo "FOUT"; }

}

break;

//list of custom checks ...

}

}
if ($invalid = 0){

$result = true;

}

else {

$result = false;

}
--8<-------------------------------------------------------

J
Jane 3/30/2007

Martijn,
we don't support the code written by our customers.

You can find some sample code snippets in the online PHP documentation or on the PHP-resource sites.

Here are some links:

http://www.php.net/docs.php

http://webcheatsheet.com/php/

http://www.php-scripts.com/php_diary/php_scripts.html

http://php.resourceindex.com/