本文整理汇总了PHP中validateRequired函数的典型用法代码示例。如果您正苦于以下问题:PHP validateRequired函数的具体用法?PHP validateRequired怎么用?PHP validateRequired使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validateRequired函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateForm
function validateForm(&$errors)
{
global $username, $password, $rePassword;
$errors = [];
if (!validateRequired($username)) {
$errors['username'][] = 'User Name is required';
} else {
if (!validateLen($username, 4)) {
$errors['username'][] = 'User Name must be at least 4 characters long';
}
}
if (!validateRequired($password)) {
$errors['password'][] = 'Password is required';
} else {
if (!validateLen($password, 5)) {
$errors['password'][] = 'Password must be at least 5 characters long';
}
if (!validateNonAlphaNumeric($password)) {
$errors['password'][] = 'Password must contain at least 1 non alphanumeric character';
}
if ($password !== $rePassword) {
$errors['rePassword'][] = 'Password not match';
}
}
return empty($errors);
}
示例2: validateData
function validateData()
{
$required = $_GET["required"];
$type = $_GET["type"];
$value = $_GET["value"];
validateRequired($required, $value, $type);
switch ($type) {
case 'number':
validateNumber($value);
break;
case 'alphanum':
validateAlphanum($value);
break;
case 'alpha':
validateAlpha($value);
break;
case 'date':
validateDate($value);
break;
case 'email':
validateEmail($value);
break;
case 'url':
validateUrl($value);
case 'all':
validateAll($value);
break;
}
}
示例3: detailsValidation
function detailsValidation(&$errors)
{
global $firstName, $lastName, $day, $month, $year;
$errors = [];
if (!validateRequired($firstName)) {
$errors['firstname'][] = 'First Name is required';
} else {
if (!validateLongerOrEqualString($firstName, 2)) {
$errors['firstname'][] = 'First Name must be at least 2 characters long';
}
}
if (!validateRequired($lastName)) {
$errors['lastname'][] = 'Last Name is required';
} else {
if (!validateLongerOrEqualString($lastName, 2)) {
$errors['lastname'][] = 'Last Name must be at least 2 characters long';
}
}
if (!validateRequired($month)) {
$errors['DOBMonth'][] = 'Month is required';
}
if (!validateRequired($day)) {
$errors['DOBDay'][] = 'Day is required';
}
if (!validateRequired($year)) {
$errors['DOBYear'][] = 'Year is required';
}
return empty($errors);
}
示例4: validateForm
function validateForm(&$errors)
{
global $firstName, $lastName, $birth_day, $birth_mount, $birth_year;
$errors = [];
if (!validateRequired($firstName)) {
$errors['first_name'][] = 'First Name is required';
} else {
if (!validateLen($firstName, 2)) {
$errors['first_name'][] = 'First Name must be at least 2 characters long';
}
}
if (!validateRequired($lastName)) {
$errors['last_name'][] = 'Last Name is required';
} else {
if (!validateLen($lastName, 2)) {
$errors['last_name'][] = 'Last Name must be at least 2 characters long';
}
}
if (!validateRequired($birth_day)) {
$errors['birthDay'][] = 'Form Of Address is required';
}
if (!validateRequired($birth_mount)) {
$errors['birthMount'][] = 'Form Of Address is required';
}
if (!validateRequired($birth_year)) {
$errors['birthYear'][] = 'Form Of Address is required';
}
return empty($errors);
}
示例5: validateForm
function validateForm(&$errors)
{
global $firstname, $surname, $birthdate;
## firstname ##
if (!validateRequired($firstname)) {
$errors['firstname'][] = 'First name is required.';
} else {
if (!validateLength($firstname, 2)) {
$errors['firstname'][] = 'Minimum length is 2.';
}
}
## surname ##
if (!validateRequired($surname)) {
$errors['surname'][] = 'Surname is required.';
} else {
if (!validateLength($surname, 2)) {
$errors['surname'][] = 'Minimum length is 2.';
}
}
## date ##
if (!validateRequired($birthdate)) {
$errors['birthdate'][] = 'Date of Birth is required.';
} else {
if (!validateDate($birthdate)) {
$errors['birthdate'][] = 'Wrong date.';
}
}
## return ##
return empty($errors) ? true : false;
}
示例6: validateForm
function validateForm(&$errors)
{
global $username, $password, $confirm_password;
$errors = [];
if (!validateRequired($username)) {
$errors['username'][] = 'Username is required';
} else {
if (!validateLongerOrEqualString($username, 4)) {
$errors['username'][] = 'Username must be at least 4 characters long';
}
}
if (!validateRequired($password)) {
$errors['password'][] = 'Password is required';
} else {
if (!validateLongerOrEqualString($password, 5)) {
$errors['password'][] = 'Password must be at least 5 characters long';
} else {
if (!validateNonAlphaNumeric($password)) {
$errors['password'][] = 'Password must contain at least 1 non alphanumeric character';
}
}
}
if ($confirm_password !== $password) {
$errors['confirm_password'][] = 'Password and Confirm Password doesn\'t match';
}
return empty($errors);
}
示例7: validateSecondForm
function validateSecondForm(&$errors)
{
global $month, $day, $year, $user_format;
if (!validateRequired($month)) {
$errors['month'][] = 'Please enter a month.';
} else {
if (!validateNumeric($month)) {
$errors['month'][] = 'This must be a number!';
}
}
if (!validateRequired($day)) {
$errors['day'][] = 'Please enter a day.';
} else {
if (!validateNumeric($day)) {
$errors['day'][] = 'This must be a number!';
}
}
if (!validateRequired($year)) {
$errors['year'][] = 'Please enter a year.';
} else {
if (!validateNumeric($year)) {
$errors['year'][] = 'This must be a number!';
}
}
if (!validateRequired($user_format)) {
$errors['user_format'][] = 'Please enter the format!';
}
return empty($errors);
}
示例8: validateForm
function validateForm(&$error)
{
global $number, $numbersArray;
$error = [];
if (!validateRequired($number)) {
$error['number'][] = 'Number can not be null.';
}
if (count($numbersArray) > 10) {
$error['count'][] = 'Number must be 10';
}
return empty($error);
}
示例9: validateForm
function validateForm(&$errors)
{
global $temperature, $conversion;
if (!validateRequired($temperature)) {
$errors['temperature'][] = 'Please enter the temperature.';
} else {
if (!validateNumeric($temperature)) {
$errors['temperature'][] = 'This must be a number!';
}
}
return empty($errors);
}
示例10: validateForm
function validateForm(&$error)
{
global $inputTemperature, $temperature;
$error = [];
if (!validateRequired($temperature)) {
$error['temperature'][] = 'Temperature can not be null.';
}
if (!validateRequired($inputTemperature)) {
$error['inputTemperature'][] = 'Choosing temperature type is required';
}
return empty($error);
}
示例11: validateForm
function validateForm(&$errors)
{
global $firstNumber, $secondNumber, $chooseAction;
$errors = [];
foreach (['firstNumber', 'secondNumber'] as $value) {
if (!validateRequired(${$value})) {
$errors[$value][] = "Number is required";
}
}
if (!validateRequired($chooseAction)) {
$errors['chooseAction'][] = "Action is required";
}
return empty($errors);
}
示例12: validateForm
function validateForm(&$errors)
{
global $product, $brand, $size, $gender, $quantity;
$errors = [];
foreach (['product', 'brand', 'gender', 'size', 'quantity'] as $value) {
if (!validateRequired(${$value})) {
$errors[$value][] = "{$value} is required";
}
if (!validateString(${$value})) {
$errors[$value][] = "{$value} must be a string";
}
}
return empty($errors);
}
示例13: validateForm
function validateForm(&$errors)
{
global $firstname, $lastname, $day, $month, $year;
$errors = [];
foreach (['firstname', 'lastname', 'day', 'month', 'year'] as $value) {
if (!validateRequired(${$value})) {
$errors[$value][] = "{$value} is required";
}
if (!validateString(${$value})) {
$errors[$value][] = "{$value} must be a string";
}
}
return empty($errors);
}
示例14: validateForm
function validateForm(&$errors)
{
global $character;
$errors = [];
foreach (['character'] as $value) {
if (!validateRequired(${$value})) {
$errors[$value][] = "{$value} is required";
}
if (!validateString(${$value})) {
$errors[$value][] = "{$value} must be a string";
}
}
if (!validateEqualString($character, 1)) {
$errors['character'][] = "You must enter a single character";
}
return empty($errors);
}
示例15: calculate
function calculate()
{
global $firstInput, $secondInput, $operation, $result, $validationErrors;
if (!validateRequired($firstInput)) {
$validationErrors['firstInput'][] = 'First number is required';
} else {
if (preg_match('/[^0-9]/', $firstInput)) {
$validationErrors['firstInput'][] = 'Please, enter numbers only';
}
}
if (!validateRequired($secondInput)) {
$validationErrors['secondInput'][] = 'Second number is required';
} else {
if (preg_match('/[^0-9]/', $secondInput)) {
$validationErrors['secondInput'][] = 'Please, enter numbers only';
} else {
if ($secondInput == 0 && $operation == '/') {
$validationErrors['secondInput'][] = 'The divisor cannot be zero';
}
}
}
if (!validateRequired($operation)) {
$validationErrors['operation'][] = 'Operation is required';
}
if ($operation == '+') {
$result = $firstInput + $secondInput;
} else {
if ($operation == '-') {
$result = $firstInput - $secondInput;
} else {
if ($operation == '*') {
$result = $firstInput * $secondInput;
} else {
if ($operation == '/') {
$result = $firstInput / $secondInput;
} else {
$result = 100;
}
}
}
}
return $result;
}