Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: really simple function...
Pages: [1] Print
Author Topic: really simple function...  (Read 212 times)
Ishida
Newbie
*
Offline Offline

Posts: 1


View Profile
really simple function...
« on: June 25, 2008, 10:31:09 AM »

validate-email: function [input] [valid][
valid: false
(if (type? input) = email! [set [valid] [true]])
return valid
]

i pass in a variable 'input' and if it is a email variable type it return true.. else it returns false.Right now, it ALWAYS returns false. -_-

I need to make a REBOL email validator.. taking baby steps right now.. baby step #1 is a problem already...
Logged
Sunanda
Full Member
***
Offline Offline

Posts: 100


View Profile
Re: really simple function...
« Reply #1 on: June 25, 2008, 04:07:27 PM »

I'm not sure if you are asking a question about improving your first function.

If you are not: then congratulations! It works which is 95% of what counts.

If you are, then I'll offer:

Code:
validate-email: function [input] [][
return email? input
]
Logged
notchent
Newbie
*
Offline Offline

Posts: 40


View Profile WWW
Re: really simple function...
« Reply #2 on: June 26, 2008, 10:14:25 PM »

Yep, it works Smiley  Are you using your function like this?

Code:
validate-email email@domain.com
validate-email "this isn't an email"
Logged

DideC
Newbie
*
Offline Offline

Posts: 26


View Profile
Re: really simple function...
« Reply #3 on: June 30, 2008, 02:30:56 AM »

What must be said is that email! is a datatype in Rebol. So it's a kind of data like integer! or tuple!

So your function just check that your input value is of type email!, not that it  is a valide email address.

In fact there is the 'email? function that just do that (feed this in a console) :

Code:
input: toto@alo.com
email? input

input: "I'm a string, not an email"
email? input

input: to-email input
email? input

In fact, email! is just a kind of string! write without quote/bracket nor space and with an @ inside.
You have to understand this to go further.
Logged
Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: really simple function...
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
August 28, 2008, 08:39:59 PM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2231 Posts in 579 Topics by 1733 Members
Latest Member: tea lover gift basket

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc