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: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
MadManSoft
Posts: 36
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: 7210
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: 36
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: 36
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 508 times
community.livecode.renegadesystems.rsIsValid.0.1.0.lce.zip
rsIsValid library extension
(14.55 KiB) Downloaded 494 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: 36
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: 176
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: 36
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: 176
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

trevix
Posts: 950
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

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

Post by trevix » Thu Mar 26, 2020 11:39 am

Hi and thanks for what you did (and are doing?).

I am developing an App that request the user for their Email and I need to verify it (not just how is composed but also if the the mailbox exists).
I have found this FREE (up to 25 Email verification a day) service, which has an API that could, probably, be implemented in LC.
https://verifalia.com/developers
Unfortunately I am not that capable with curl, basic Auth, etc

So I wonder if someone can help me out on developing this verification that could be a nice addition to this set of functions.
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

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

Post by bogs » Thu Mar 26, 2020 12:01 pm

Before you get too carried away, trevix, you *do* know there are like, a gazillion throw away email sites out there that give you all kinds of real live email boxes that you can receive mail at, respond to it, click links from it, etc..., right? They last just long enough to 'verify' that it is an active box, then they go away.
Image

trevix
Posts: 950
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

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

Post by trevix » Thu Mar 26, 2020 12:08 pm

Yes, off course.
Most users won't go in the trouble of creating a temporary email just for using an advanced part of my App.
What I am talking here is an unuttended email verification, done by my standalone.
Since I collect user emails (for newsletter, privacy statement included) using my DB server connected with the standalone, I cannot do a verification manually for each one (supposing that my standalone will have a high number of users willing to share their email).
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

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

Post by bogs » Thu Mar 26, 2020 12:22 pm

trevix wrote:
Thu Mar 26, 2020 12:08 pm
Most users won't go in the trouble of creating a temporary email just for using an advanced part of my App.
Well, I'll be the first to admit I'm not using your app, so I am probably not going to fall into that 'most users' where your app pertains, but I'm not sure what you mean by creating a temp address being any kind of trouble.

For instance, you open the page here, you have an email address, it really isn't that much work. It is so little trouble I keep the page open and use it for any company that requires me to give them an email address for any reason.

However, I've derailed the topic long enough, what you do with the information above is up to you :)
Image

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

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

Post by bangkok » Thu Mar 26, 2020 5:19 pm

trevix wrote:
Thu Mar 26, 2020 11:39 am
https://verifalia.com/developers
Unfortunately I am not that capable with curl, basic Auth, etc
[sorry to hijack the thread]

Easy.

STEP1 : create an ID for the job

Code: Select all

----- email address you want to check
   put "{entries: [{ inputData: 'themail@iwantocheck.com'}]}" into tJSON
   
---- your verifalia username and password
   set the httpHeaders to "Authorization: Basic" && base64Encode("fd1jkSSDQSKJDHQSKD:mypassword")&cr&"Content-Type: application/json"
   POST tJSON to  "https://api.verifalia.com/v2.1/email-validations"
   
   put JSONToArray(it) into tArray

---this is the ID that you have just created
put tArray["overview"]["id"] into tID


STEP 2 : with the ID, fetch the result

Code: Select all

 set the httpHeaders to "Authorization: Basic" && base64Encode("fd1jkSSDQSKJDHQSKD:mypassword")
   
   put "https://api.verifalia.com/v2.1/email-validations/"&tID into tUrl
   
   put url tUrl  into tResponse
   
----voila : another JSON with all the data
   answer tResponse
For each query you send to Verifalia, you need to "id" yourself. Their API has several means for that. But the easiest way is "HTTP Basic Auth"

With livecode = to write a special httpheaders, before to issue your query (usually POST or GET)

Then to send a query = POST

Or GET = PUT URL tUrl into

Verifalia seems cool. You can create a free account with 25 checks per day. So it's a good way to test their API.

trevix
Posts: 950
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

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

Post by trevix » Thu Mar 26, 2020 7:04 pm

Thanks so much.
It is perfect. What an help!
In case some need it, see the attached stack.
Attachments
VerifyEmail.livecode.zip
(2.33 KiB) Downloaded 344 times
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

Post Reply

Return to “Making IDE Plugins”