function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BigThorBigThor 

Code validate IBAN, SWIFT and EAN-13

Hi,

 

anyone have the code for validate IBAN, SWIFT and EAN-13 ? or any website with the code ?

 

Thanks for all

 

Saludos !!

BigThorBigThor

Hi,

 

I started creating the functions for validate IBAN, SWIFT and EAN-13, this function validate SWIFT

 

public Boolean validateSWIFT(String swift){
    	System.debug('SWIFT: '+ swift);
    	String patron = '^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$';
    	
    	Pattern myPattern = Pattern.compile(patron);
    	
    	Matcher myMatcher = myPattern.matcher(swift);
    	
    	return myMatcher.matches();
}

 Coming soon function validate EAN

 

Saludos !!

BigThorBigThor

Hi,

 

this code validate EAN code

 

public Boolean validateEAN(String ean){
    	String validChars = '0123456789';
    	String digit;
    	String originalCheck;
    	Integer even;
    	Integer odd;
    	Integer total;
    	Integer originalCheck;
    	
    	for(Integer i = 0; i < validChars.length(); i++){
    		digit = ean.substring(i, i+1);
    		if(!(validChars.contains(digit)))
    			return false;
    	}
    	/*Add five 0 the code has only 8 digits*/
    	if(ean.length() == 8)
    		ean = '00000'+ ean;
    	else if(ean.length() != 13) /*Chack 13 digits otherwise*/
    		return false;
    	
    	/*Ger the check number*/
    	originalCheck = ean.substring(ean.length()-1);
    	ean = ean.substring(0, ean.length()-1);
    	
    	/*Add even number together*/
    	
    	even = Integer.valueOf(ean.substring(1,2)) + Integer.valueOf(ean.substring(3,4)) + Integer.valueOf(ean.substring(5,6)) + Integer.valueOf(ean.substring(7,8)) + Integer.valueOf(ean.substring(9,10)) + Integer.valueOf(ean.substring(11,12));
    	even = even * 3;
    	
    	/*Add odd numbers together*/
    	odd = Integer.valueOf(ean.substring(0,1)) + Integer.valueOf(ean.substring(2,3)) + Integer.valueOf(ean.substring(4,5)) + Integer.valueOf(ean.substring(6,7)) + Integer.valueOf(ean.substring(8,9)) + Integer.valueOf(ean.substring(10,11)); 
    	/*Add two totals together*/
    	total = even + odd;
    	/*Calculate the checksum*/
    	checksum = math.mod(total,10);
    	/*If result is not 0 then take away 10*/
    	if(checksum != 0)
    		checksum = 10 - checksum;
    	
    	/*Return the result*/
    	if(checksum != Integer.valueOf(originalCheck))
    		return false;
    	
    	return true;
    }

 

Only one more :D

Penn HarrisPenn Harris
I got full ideas for validating EAN-13 (http://www.barcodelib.com/net_barcode/barcode_symbologies/ean13.html) from:
http://stackoverflow.com/questions/10143547/how-do-i-validate-a-upc-or-ean-code
sean dalesean dale
Recently i am testing barcode generator in .net (http://www.keepdynamic.com/barcoding/dotnet-barcode-generator.shtml) applications.I found a web site with the code of EAN13 in C#.NET,VB.NET,ASP.NET,.NET WinForms and so on.I hope you will find what you need.
Check this:http://www.keepdynamic.com/dotnet-barcode/barcode/ean-13.shtml