-
Notifications
You must be signed in to change notification settings - Fork 0
Validating
fkrzski edited this page Feb 2, 2022
·
1 revision
FOO=BAR
$dotenv = new Dotenv('path\to\your\file\.env');
$dotenv->start();
$dotenv->validator()->validate([
'FOO' => 'required'
]);
ALNUM1="alpha"
ALNUM2='12 45'
ALNUM3=alpha12345
$dotenv = new Dotenv('path\to\your\file\.env');
$dotenv->start();
$dotenv->validator()->validate([
'ALNUM1' => 'alnum',
'ALNUM2' => 'alnum',
'ALNUM3' => 'alnum',
]);
LETTERS1="letters"
LETTERS2='lett ers'
LETTERS3=letters
$dotenv = new Dotenv('path\to\your\file\.env');
$dotenv->start();
$dotenv->validator()->validate([
'LETTERS1' => 'letters',
'LETTERS2' => 'letters',
'LETTERS3' => 'letters',
]);
INTEGER1="1"
INTEGER2='2'
INTEGER3=3
$dotenv = new Dotenv('path\to\your\file\.env');
$dotenv->start();
$dotenv->validator()->validate([
'INTEGER1' => 'integer',
'INTEGER2' => 'integer',
'INTEGER3' => 'integer',
]);
FLOAT1="1.1"
FLOAT2='2.432'
FLOAT3=.033
$dotenv = new Dotenv('path\to\your\file\.env');
$dotenv->start();
$dotenv->validator()->validate([
'FLOAT1' => 'float',
'FLOAT2' => 'float',
'FLOAT3' => 'float',
]);
BOOL='true'
BOOL2=false
BOOL3=yes
BOOL4=no
BOOL5=on
BOOL6="off"
BOOL7=1
BOOL8=0
$dotenv = new Dotenv('path\to\your\file\.env');
$dotenv->start();
$dotenv->validator()->validate([
'BOOL1' => 'boolean',
'BOOL2' => 'boolean',
'BOOL3' => 'boolean',
'BOOL4' => 'boolean',
'BOOL5' => 'boolean',
'BOOL6' => 'boolean',
'BOOL7' => 'boolean',
'BOOL8' => 'boolean',
]);
MULTIPLE="1.1"
$dotenv = new Dotenv('path\to\your\file\.env');
$dotenv->start();
$dotenv->validator()->validate([
'MULTIPLE' => 'required|float',
]);