app/src/main/java/com/treslines/pagsegurodemo/PagSeguroBuyer.java
private void validate(final String completeName, final String bornDate, final String cpf, final String email){
        if(completeName.isEmpty()){
            throw new IllegalArgumentException("Name can not be empty!");
        }
        if(completeName.split(" ").length<2){
            throw new IllegalArgumentException("Name must be composed at a minimum of two sequences of characters such as first name and second name!");
        }
        if(completeName.length()>50){
            throw new IllegalArgumentException("Name can not exceed 50 characters!");
        }

        if(bornDate.isEmpty()){
            throw new IllegalArgumentException("Born date can not be empty!");
        }
        if(bornDate.length()!=10){
            throw new IllegalArgumentException("The format of born date must be dd/mm/yyyy!");
        }
        try{
            new SimpleDateFormat("dd/MM/yyyy").parse(bornDate);
        }catch (Exception e){
            throw new IllegalArgumentException("The format of born date must be dd/mm/yyyy!");
        }

        if(cpf.isEmpty()){
            throw new IllegalArgumentException("CPF can not be empty!");
        }
        if(cpf.length()!=11){
            throw new IllegalArgumentException("The CPF must contain exactly 11 digits!");
        }
        try{
            Double.valueOf(cpf);
        }catch(Exception e){
            throw new IllegalArgumentException("The CPF must be composed of numbers only!");
        }
        if(email.isEmpty()){
            throw new IllegalArgumentException("Email can not be empty!");
        }
        if(email.length()>60){
            throw new IllegalArgumentException("Email can not exceed 60 characters!");
        }
        String regex = "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$";
        if(!email.matches(regex)){
            throw new IllegalArgumentException("Invalid Email address!");
        }
    }
/** validation defined acc. to pagseguro's web documentation */
validation defined acc. to pagseguro's web documentation
validation defined acc . to pagseguro ' s web documentation
private void validate(final String completeName, final String bornDate, final String cpf, final String email){
        if(completeName.isEmpty()){
            throw new IllegalArgumentException("Name can not be empty!");
        }
        if(completeName.split(" ").length<2){
            throw new IllegalArgumentException("Name must be composed at a minimum of two sequences of characters such as first name and second name!");
        }
        if(completeName.length()>50){
            throw new IllegalArgumentException("Name can not exceed 50 characters!");
        }
        if(bornDate.isEmpty()){
            throw new IllegalArgumentException("Born date can not be empty!");
        }
        if(bornDate.length()!=10){
            throw new IllegalArgumentException("The format of born date must be dd/mm/yyyy!");
        }
        try{
            new SimpleDateFormat("dd/MM/yyyy").parse(bornDate);
        }catch (Exception e){
            throw new IllegalArgumentException("The format of born date must be dd/mm/yyyy!");
        }
        if(cpf.isEmpty()){
            throw new IllegalArgumentException("CPF can not be empty!");
        }
        if(cpf.length()!=11){
            throw new IllegalArgumentException("The CPF must contain exactly 11 digits!");
        }
        try{
            Double.valueOf(cpf);
        }catch(Exception e){
            throw new IllegalArgumentException("The CPF must be composed of numbers only!");
        }
        if(email.isEmpty()){
            throw new IllegalArgumentException("Email can not be empty!");
        }
        if(email.length()>60){
            throw new IllegalArgumentException("Email can not exceed 60 characters!");
        }
        String regex = "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$";
        if(!email.matches(regex)){
            throw new IllegalArgumentException("Invalid Email address!");
        }
    }
private void validate ( final String completeName , final String bornDate , final String cpf , final String email ) { if ( completeName . isEmpty ( ) ) { throw new IllegalArgumentException ( "Name can not be empty!" ) ; } if ( completeName . split ( " " ) . length < 2 ) { throw new IllegalArgumentException ( "Name must be composed at a minimum of two sequences of characters such as first name and second name!" ) ; } if ( completeName . length ( ) > 50 ) { throw new IllegalArgumentException ( "Name can not exceed 50 characters!" ) ; } if ( bornDate . isEmpty ( ) ) { throw new IllegalArgumentException ( "Born date can not be empty!" ) ; } if ( bornDate . length ( ) != 10 ) { throw new IllegalArgumentException ( "The format of born date must be dd/mm/yyyy!" ) ; } try { new SimpleDateFormat ( "dd/MM/yyyy" ) . parse ( bornDate ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "The format of born date must be dd/mm/yyyy!" ) ; } if ( cpf . isEmpty ( ) ) { throw new IllegalArgumentException ( "CPF can not be empty!" ) ; } if ( cpf . length ( ) != 11 ) { throw new IllegalArgumentException ( "The CPF must contain exactly 11 digits!" ) ; } try { Double . valueOf ( cpf ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "The CPF must be composed of numbers only!" ) ; } if ( email . isEmpty ( ) ) { throw new IllegalArgumentException ( "Email can not be empty!" ) ; } if ( email . length ( ) > 60 ) { throw new IllegalArgumentException ( "Email can not exceed 60 characters!" ) ; } String regex = "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$" ; if ( ! email . matches ( regex ) ) { throw new IllegalArgumentException ( "Invalid Email address!" ) ; } }
validation defined acc.
validation defined acc .