Home » Validate » Validate_FI » Manual
Specific validation methods for data used in Finland. See also: Latest auto-generated API documentation Package information on pear.php.net
Introduction
Introduction – introduction to Validate_FI
Description
Specific validation methods for data used in Finland.
Usage
General usage
Every module of Validate follows the same philosophy. Propose some validation method which returns a boolean result.
Some methods have some optional parameters to set stronger checks.
Sample using phoneNumber()
<?php
// Include the package
require_once 'Validate/FI.php';
// Validate Finnish telephone number
$phoneNumber = '+358 40 1234567';
if ( Validate_FI::phoneNumber($phoneNumber) ) {
print 'Valid';
} else {
print 'Not valid!';
}
?>
Output:
Valid
Validate_FI::postalCode
Validate_FI::postalCode() – Validate Finnish postal code
Synopsis
require_once 'Validate/FI.php';
bool Validate_FI::postalCode
(
string $number
,
bool $strong
)
Description
Validate Finnish postal code.
Five digit postal code, maybe with a leading 'FI-' (XXXXX or FI-XXXXX).
An optional parameter for activate strong checks using a list of postcodes (not implemented).
Parameter
-
string
$number -
The postal code to be validated
-
boolean
$strong -
optional; strong checks (e.g. against a list of postal codes)(not implemented)
Return value
boolean - true if postal code is valid, false otherwise
Example
Using postalCode()
<?php
// Include the package
require_once 'Validate/FI.php';
$postalCode = '00100';
if ( Validate_FI::postalCode($postalCode) ) {
print 'Valid';
} else {
print 'Not valid!';
}
?>
Validate_FI::phoneNumber
Validate_FI::phoneNumber() – Validate Finnish telephone number
Synopsis
require_once 'Validate/FI.php';
bool Validate_FI::phoneNumber
(
string $number
)
Description
Validate Finnish telephone number.
Simple check: number must be numeric when (, ), -, +, ., ' ' chars are removed and 3-20 digit number.
Parameter
-
string
$number -
The telephone number to be validated
Return value
boolean - true if telephone number is valid, false otherwise
Example
Using phoneNumber()
<?php
// Include the package
require_once 'Validate/FI.php';
$phoneNumber = '+358 40 1234567';
if ( Validate_FI::phoneNumber($phoneNumber) ) {
print 'Valid';
} else {
print 'Not valid!';
}
?>
Validate_FI::carLicensePlate
Validate_FI::carLicensePlate() – Validate Finnish car license plate number
Synopsis
require_once 'Validate/FI.php';
bool Validate_FI::carLicensePlate
(
string $number
)
Description
Validate Finnish car license plate number. Format: AAA-XXX, CD-XXXX or C-XXXXX. First or only number cannot be zero.
AAA-XXX: AAA is 2-3 letters UPPERCASE A-Z + ÅÄÖ and XXX is 1-3 numbers.
CD-XXXX: CD- and XXXX is 1-4 numbers (diplomat licence plate).
C-XXXXX: C- and XXXXX is 1-5 numbers (other tax-free diplomat licence plate).
Parameter
-
string
$number -
The license plate number to be validated
Return value
boolean - true if license plate number is valid, false otherwise
Example
Using carLicensePlate()
<?php
// Include the package
require_once 'Validate/FI.php';
$carLicensePlate = 'ABC-123';
if ( Validate_FI::carLicensePlate($carLicensePlate) ) {
print 'Valid';
} else {
print 'Not valid!';
}
?>
Validate_FI::bikeLicensePlate
Validate_FI::bikeLicensePlate() – Validate Finnish motorbike license plate number
Synopsis
require_once 'Validate/FI.php';
bool Validate_FI::bikeLicensePlate
(
string $number
)
Description
Validate Finnish motorbike license plate number. Format: AAAXXX. First or only number cannot be zero.
Where AAA is 2-3 letters UPPERCASE A-Z + ÅÄÖ and XXX is 1-3 numbers. Letters and numbers are actually in separate lines.
Parameter
-
string
$number -
The license plate number to be validated
Return value
boolean - true if license plate number is valid, false otherwise
Example
Using bikeLicensePlate()
<?php
// Include the package
require_once 'Validate/FI.php';
$bikeLicensePlate = 'ABC123';
if ( Validate_FI::bikeLicensePlate($bikeLicensePlate) ) {
print 'Valid';
} else {
print 'Not valid!';
}
?>
Validate_FI::pin
Validate_FI::pin() – Validate Personal Identity Number (HETU)
Synopsis
require_once 'Validate/FI.php';
mixed Validate_FI::pin
(
string $number
,
bool $info
)
Description
Validate Personal Identity Number (HETU).
The Finnish PIN number (HETU) aka Social Security Number (SSN) is a 11 digit number with birthdate as ddmmyycxxxy where c is century, xxx is a three digit individual number and the last digit is a control number (y).
If xxx is odd it's a male PIN number and if even a female.
Return gender (Male or Female) and date of birth (YYYY-MM-DD) in array if PIN is valid, is available by switching $info (2nd parameter) to true.
Example: 010101-123N would be a male and born in 1st of January 1901.
Parameter
-
string
$number -
PIN number to be validated
-
boolean
$info -
optional; Return gender and date of birth on success
Return value
mixed - Returns true or false if $info = false or gender (Male or Female) and date of birth (YYYY-MM-DD) in array if PIN is valid, false otherwise
Example
Using pin() in default mode
<?php
// Include the package
require_once 'Validate/FI.php';
$pin = '010101-123N';
if ( Validate_FI::pin($pin) ) {
print 'Valid';
} else {
print 'Not valid!';
}
?>
Using pin() with $info = TRUE
<?php
// Include the package
require_once('Validate/FI.php');
$pin = '010101-123N';
if ( $userinfo = Validate_FI::pin($pin, true) ) {
print_r($userinfo);
} else {
print 'Not valid!';
}
?>
Output:
Array
(
[0] => Male
[1] => 1901-01-01
)
Validate_FI::finuid
Validate_FI::finuid() – Validate Finnish Unique Identification Number (SATU)
Synopsis
require_once 'Validate/FI.php';
bool Validate_FI::finuid
(
string $number
)
Description
Validate Finnish Unique Identification Number (SATU). Format: xxxxxxxxy.
FINUID (SATU) is a 9 digit number. The last digit is a control number.
Parameter
-
string
$number -
FINUID number to be validated
Return value
boolean - true if FINUID is valid, false otherwise
Example
Using finuid()
<?php
// Include the package
require_once 'Validate/FI.php';
$finuid = '10011187H';
if ( Validate_FI::finuid($finuid) ) {{
print 'Valid';
} else {
print 'Not valid!';
}
?>
Validate_FI::businessId
Validate_FI::businessId() – Validate Finnish Business ID (Y-tunnus)
Synopsis
require_once 'Validate/FI.php';
bool Validate_FI::businessId
(
string $number
)
Description
Validate Finnish Business ID (Y-tunnus). Format: xxxxxxx-y.
The Finnish Business ID number (Y-tunnus) is a 9 digit number. The last digit is a control number (y).
Parameter
-
string
$number -
Business ID number to be validated
Return value
boolean - true if Business ID is valid, false otherwise
Example
Using businessId()
<?php
// Include the package
require_once 'Validate/FI.php';
$businessId = '1572860-0';
if ( Validate_FI::businessId($businessId) ) {
print 'Valid';
} else {
print 'Not valid!';
}
?>
Validate_FI::partyId
Validate_FI::partyId() – Validate Finnish Party Identification number (OVT-tunnus)
Synopsis
require_once 'Validate/FI.php';
bool Validate_FI::partyId
(
integer $number
)
Description
Validate Finnish Party Identification number (OVT-tunnus).
The Finnish Party Identification number (OVT-tunnus) is a 12-17 digit number and it is generated from Business ID.
Example: 0037AAAAAAAABBBBB, 0037 indicates Finland, AAAAAAAA is the Business ID and BBBBB is optional organization number.
Parameter
-
integer
$number -
Party Identification number to be validated
Return value
boolean - true if number is valid, false otherwise
Example
Using partyId()
<?php
// Include the package
require_once 'Validate/FI.php';
$partyId = '003715728600';
if ( Validate_FI::partyId($partyId) ) {
print 'Valid';
} else {
print 'Not valid!';
}
?>
Validate_FI::vatNumber
Validate_FI::vatNumber() – Validate Finnish Value Added Tax number (ALV-numero)
Synopsis
require_once 'Validate/FI.php';
bool Validate_FI::vatNumber
(
string $number
)
Description
Validate Finnish Value Added Tax number (ALV-numero). Format: FIXXXXXXXX.
The Finnish VAT number (ALV-numero) is maximum of 14 digits and is generated from Business ID.
Parameter
-
string
$number -
VAT number to be validated
Return value
boolean - true if VAT number is valid, false otherwise
Example
Using vatNumber()
<?php
// Include the package
require_once 'Validate/FI.php';
$vatNumber = 'FI15728600';
if ( Validate_FI::vatNumber($vatNumber) ) {
print 'Valid';
} else {
print 'Not valid!';
}
?>
Validate_FI::bankAccount
Validate_FI::bankAccount() – Validate Finnish bank account number
Synopsis
require_once 'Validate/FI.php';
bool Validate_FI::bankAccount
(
string $number
)
Description
Validate Finnish bank account number. Format: XXXXXX-XXXXXXXX, 6 digits, - and 2-8 digits.
This method checks the bank account number according to Finnish Bank Association.
Parameter
-
string
$number -
Finnish bank account number to be validated
Return value
boolean - true if bank account is valid, false otherwise
Example
Using bankAccount()
<?php
// Include the package
require_once 'Validate/FI.php';
$bankAccount = '159030-776';
if ( Validate_FI::bankAccount($bankAccount) ) {
print 'Valid';
} else {
print 'Not valid!';
}
?>
Validate_FI::refNum
Validate_FI::refNum() – Validate Finnish bank reference number
Synopsis
require_once 'Validate/FI.php';
bool Validate_FI::refNum
(
string $number
)
Description
Validate Finnish bank reference number.
This method checks the bank reference number according to Finnish Bank Association.
Parameter
-
string
$number -
Finnish bank reference number to be validated (spaces and dashes tolerated)
Return value
boolean - true if reference number is valid, false otherwise
Example
Using refNum()
<?php
// Include the package
require_once 'Validate/FI.php';
$refNum = '61 74354';
if ( Validate_FI::refNum($refNum) ) {
print 'Valid';
} else {
print 'Not valid!';
}
?>
Validate_FI::creditCard
Validate_FI::creditCard() – Validate credit card number
Synopsis
require_once 'Validate/FI.php';
bool Validate_FI::creditCard
(
string $number
)
Description
Validate credit card number.
This method checks the credit card number according to Luhn algorithm. This method doesn't guarantee that the card is legitimate.
Parameter
-
string
$number -
credit card number to be validated (spaces and dashes tolerated)
Return value
boolean - true if credit card number is valid, false otherwise
Example
Using creditCard()
<?php
// Include the package
require_once 'Validate/FI.php';
$creditCard = '5427 0073 1297 6425';
if ( Validate_FI::creditCard($creditCard) ) {
print 'Valid';
} else {
print 'Not valid!';
}
?>