logo

A Reason Not to Like Notes

I've been working on a user registration "component" for a Domino database. Something to let users register for access and then, once logged in, change their passwords.

As part of both processes the password entered is validated and checked it's of a certain quality. It has to be a certain length as well as containing both uppercase and lowercase letters along with some numbers. So, "P4ssw0rD" is ok but "p4ssw0rd" and "P4SSW0RD" aren't.

I needed to perform this validation both in @Formula and LotusScript.

The @Formula is simple:

@Length(Password)>6 & @Matches(Password; "*{A-Z}*") 
 & @Matches(Password; "*{a-z}*") & @Matches(Password; "*{0-9}*")

It would follow that the LotusScript equivalent would be:

If Len(doc.Password(0))>6 
 And doc.Password(0) Like "*[A-Z]*" 
 And doc.Password(0) Like "*[a-z]*" 
 And doc.Password(0) Like "*#*" Then

But, wait. It looks like there's a bug in LotusScript which means all the following are True:

"ABCDE" Like "*[a-z]*"
"abcde" Like "*[A-Z]*"
"AbCdE" Like "*[A-Z]*"

The only way round this I've found is to use the whole alphabet, like so:

If Len(doc.Password(0))>6 
 And doc.Password(0) Like "*[ACBDEFGHIJKLMNOPQRSTUVWXYZ]*"
 And doc.Password(0) Like "*[acbdefghijklmnopqrstuvwxyz]*" 
 And doc.Password(0) Like "*#*" Then

You've got to like love Notes! An hour of my day wasted...

Comments

    • avatar
    • Mike
    • Thu 16 Feb 2012 07:10 AM

    I know the feeling.

    Of course, all other options other than Notes are not bug free either. Maybe an hour isn't too bad compared to some other tools?

    • avatar
    • Jeroen Jacobs
    • Thu 16 Feb 2012 07:19 AM

    I'm not sure it's a bug...

    By default, string comparisons in LotusScript are case-insensitive, and "like" is a kind of string comparision...

    What happens if you put in "Option compare Case" before you start comparing?

      • avatar
      • Jeroen Jacobs
      • Thu 16 Feb 2012 07:24 AM

      Forget what I said... "Option Compare Case" seems to be the default anyway ...

      Hide the rest of this thread

      1. Was about to say the Help files says it's case-sensitive by default and my code doesn't change the compare option at any point.

  1. Hi,

    if you use "Option Compare Binary" the Like-Operator works correctly.

    Sven

      • avatar
      • Jake Howlett
      • Thu 16 Feb 2012 01:28 PM

      Never liked the idea of using either ls2j or createobject in LS. I'd rather just rewrite the whole agent in java!

  2. Forget about anything serious about regular expressions in LS. Just use Java and LJ2J if you need to work with LS. Tommy Valand wrote about it http://dontpanic82.blogspot.com/2007/10/simple-ls2j-regular-expression-class.html. It has served me well.

    • avatar
    • Erik Brooks
    • Thu 16 Feb 2012 12:25 PM

    Ummm.....

    Why not just Evaluate() the same @Formula?

    Dim s as String

    s = |

    @Length(Password)>6 & @Matches(Password; "*{A-Z}*")

    & @Matches(Password; "*{a-z}*") & @Matches(Password; "*{0-9}*")

    |

    Dim vResult as Variant

    vResult = Evaluate(s, yourDoc)

    Print (vResult(0))

      • avatar
      • Jake Howlett
      • Thu 16 Feb 2012 01:25 PM

      Because evalaute() is cheating.

      Show the rest of this thread

    • avatar
    • Jaap
    • Fri 17 Feb 2012 07:21 AM

    Hi Jake, You need to love Notes, I am not gonna tell you how many hours I wasted in that other M.... world ;-) where you needs A4 pages of code while the @formula is just within a page rule length.

    LOVE NOTES

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Thu 16 Feb 2012

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content