troubleshooting Question

XJS: how to throw error if no match found

Avatar of badtz7229
badtz7229Flag for United States of America asked on
8 Comments1 Solution211 ViewsLast Modified:
I have the following xml file that I am reading via xslt

Currently, I have logic where if the card number does not satisfy the RegExp then an error is thrown "Number is invalid"

However, I need to change my logic for a special case where if a VI number is entered that fails the RegExp but passes the binExp then DO NOT throw error all while still capturing error for other cards where it throws error if RegExp fails on them.

I had the following logic:

if (cardType != "VI" &&  (binExp && (binExp.test(cardNumber))) ) 

      if (RegExp && (!RegExp.test(cardNumber)))
            throw "Number is invalid";                        
but this won't work for an invalid MC. I want it throw error.
Example, I expect
5204730000001003 to pass
5704730000001003 to fail //but my logic doesn't throw error here. when it should.

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros