rsIsValid(Validation functions) and a call for contributors

Are you developing tools to extend the LiveCode environment? This is the place to talk about the nuts and bolts of extending our nuts and bolts. If you want to use a LiveCode or third party Environment extension, visit the Using Evironment Extensions forum.

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
MadManSoft
Posts: 35
Joined: Fri Apr 12, 2013 9:15 pm

rsIsValid(Validation functions) and a call for contributors

Post by MadManSoft » Fri Feb 26, 2016 9:08 pm

Hi All,

I'm in process of creating a library extension for LC 8 that contains a set of
functions to provide data validation. I'm basing my initial set of functions on
a subset of the functions provided in ColdFusion, which I use for much of my backend development.

This extension will be available for free and under the MIT license as I’m trying to avoid any issues with including this in both the community edition as well as Indy and Business editions of LC. Source code is available on GitHub.

Validation is a very important part of ensuring the data being inputted is what is expected and preventing things like SQL injection attacks, etc. We all have our own different methods of doing validation and as with most things, some methods are better than others.

I'm putting out a call for contributors to provide their solutions to different validation types, both included and not included in the current iteration of rsIsValid.

You do not have to know anything about LiveCode Builder, you can just submit your current LiveCode Script. I will work to put it into the extension via LCB. If you do contribute code, please make sure that any needed attribution is included in your code comments.

Below is the list of functions I am currently working on as well as the link to GitHub. If you have a validation function to contribute, you can post below in this thread or fork it on GitHub. I plan to have the initial functions done, packaged and uploaded to the extension area of LiveCode by the end of next week. The development branch on GitHub is https://github.com/renegadesteve/rsIsVa ... evelopment

My hope is that we can together build a very robust library of validation tools for the entire LC community.

Best,

Steve MacLean

------------------------------------------------------------------------------------------
Initial rsIsValid functions - *Included in first release

Funtion Name (value(s)) - Description

rsIsValidCC(creditcard number) - Checks if the value is a 13-16 digit number conforming to the mod10 algorithm. Returns true if the value is or false otherwise.

rsIsValidEmail(email address) - Checks if the value is a vaild email address. Returns true if the value is or false otherwise.

rsIsValidRange(number, min, max) - Checks if the number value is between the min and max values. Returns true if the value is or false otherwise.

rsIsValidSQLDate(datetime) - Check if the value is a SQL datetime of the format yyyy-mm-dd hh:mm:ss. Returns true if the value is or false otherwise.

rsIsValidSSN(US social security number) - Checks if the value is a US Social Security Number. Returns true if the value is or false otherwise.

rsIsValidUSPhone(US telephone number) - Checks if the value is a US telephone number. Returns true if the value is or false otherwise.

rsIsValidURL(URL) Checks if value is an http, https, ftp, ftps, mailto, or news URL. Returns true if the value is or false otherwise.

rsIsValidUUID(UUID) - Checks if the value is a Universally Unique Identifier of the form "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" where ‘ X’ is a hexadecimal number. Returns true if the value is or false otherwise.

rsIsValidUSDate(US Date) - Checks to see if the value is a US Date of the format mm/dd/yyyy (hh:mm:ss), with 2 digit days and months, 4 digit years. Returns true if the value is or false otherwise.

rsIsValidUSZip(US zip code) - Checks to see if the value is a US 5- or 9-digit format ZIP code. Returns true if the value is or false otherwise.
------------------------------------------------------------------------------------------
Additional functions I would like to add/have added

rsIsValidDateTime(date-time) - Checks to see if the value is any date-time combo.

rsIsValidEuroDateTime(European formatted date-time) - Checks to see if the value is a EU formatted date-time combo.

rsIsValidUSDateTime(US formatted date-time) Checks to see if the value is a US formatted date-time combo.

Any other validation function that LC users have found they needed and want to contribute!!!!

EDIT: Removed unnecessary, duplicated functions from list
EDIT2: Updated functions and some descriptions
Last edited by MadManSoft on Sun Mar 20, 2016 11:48 pm, edited 7 times in total.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4561
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: rsIsValid(Validation functions) and a call for contribut

Post by jacque » Fri Feb 26, 2016 9:47 pm

Sounds very useful, thanks for putting this together. I will see if I have any others.

Just curious, is there a difference between your integer and array checks and the built-in LiveCode operators "is an integer" and "is an array"?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

MadManSoft
Posts: 35
Joined: Fri Apr 12, 2013 9:15 pm

Re: rsIsValid(Validation functions) and a call for contribut

Post by MadManSoft » Sat Feb 27, 2016 3:37 am

Hi Jacque,

It doesn't look like there is any difference, so I will remove those from the list along with:

Any
Binary
Boolean
Float

My goal is not to replace existing functions like those.

Thanks!

MadManSoft
Posts: 35
Joined: Fri Apr 12, 2013 9:15 pm

Re: rsIsValid(Validation functions) and a call for contribut

Post by MadManSoft » Sun Mar 20, 2016 11:45 pm

Hi All,

I'm please to announce the first pass of rsIsValid. It is a livecode 8 library widget. The functions in the first post are the ones currently available.

I'm also looking at include some that other folks have sent me for inclusion in the future.

If you have issues, or find a test case that doesn't work like you think it should, please let me know here.

You can download both the example file and the livecode 8 extension below, I've attached them to this post.

Also, you can find everything including the LCB source on github: https://github.com/renegadesteve/rsIsValid

If you want to add to rsIsValid please do so! This is a project for the community and community input is more than welcome!

Best,

Steve
Attachments
rsIsValid example.livecode.zip
rsIsValid example file
(8.61 KiB) Downloaded 99 times
community.livecode.renegadesystems.rsIsValid.0.1.0.lce.zip
rsIsValid library extension
(14.55 KiB) Downloaded 96 times

peter-b
Posts: 182
Joined: Thu Nov 20, 2014 2:14 pm
Location: LiveCode Ltd.

Re: rsIsValid(Validation functions) and a call for contribut

Post by peter-b » Mon Mar 21, 2016 4:31 pm

Hey Steve,

This looks like a really useful idea!

A quick suggestion: when you make a numbered release, why not make a release on GitHub? That way people can easily see what GitHub changes relate to which version, and also GitHub provides a convenient way to download the source code from releases.
LiveCode Open Source Team — @PeterTBBrett — peter.brett@livecode.com

MadManSoft
Posts: 35
Joined: Fri Apr 12, 2013 9:15 pm

Re: rsIsValid(Validation functions) and a call for contribut

Post by MadManSoft » Mon Mar 21, 2016 7:33 pm

Hi Peter,

Thanks! I hope it helps.

I've added the release on GitHub as you suggested :D

okk
Posts: 86
Joined: Wed Feb 04, 2015 11:37 am

Re: rsIsValid(Validation functions) and a call for contributors

Post by okk » Wed Jul 25, 2018 11:33 am

Thanks for the great work and for sharing. It saved me a lot of work. Has this project evolved? I am looking for a gps coordinate validator. Regex patterns is still a step beyond me.
Oliver

MadManSoft
Posts: 35
Joined: Fri Apr 12, 2013 9:15 pm

Re: rsIsValid(Validation functions) and a call for contributors

Post by MadManSoft » Wed Jul 25, 2018 2:27 pm

Glad it helped!

It really hasn't moved forward, but that looks like an interesting addition.

Can't promise anything soon, but will look into it.

okk
Posts: 86
Joined: Wed Feb 04, 2015 11:37 am

Re: rsIsValid(Validation functions) and a call for contributors

Post by okk » Sun Aug 26, 2018 11:08 am

Hi,
I gave it a try to create a gps validator, based on your other functions. It seems to work but I haven't tested all possible wrong inputs...

Code: Select all

function validateGPS pGPS
   put "^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$" into tSchemeRegex
   put matchText(pGPS, tSchemeRegex,tScheme) into validateresult
   if validateresult is false then 
      return false
   else
      return true
   end if
end validateGPS
Let me know if you spot a mistake.
Best
Oliver

Post Reply

Return to “Extending LiveCode”