Skip to content

Commit

Permalink
Merge branch 'main' into d5df3-add-block-shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
JhumanJ authored Sep 18, 2023
2 parents 64aae01 + 402e74e commit b62d7ad
Show file tree
Hide file tree
Showing 18 changed files with 346 additions and 124 deletions.
2 changes: 1 addition & 1 deletion app/Http/Requests/AnswerFormRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private function getPropertyRules($property): array
}
return $this->getRulesForDate($property);
case 'phone_number':
return [new ValidPhoneInputRule];
return ['string', 'min:6', new ValidPhoneInputRule];
default:
return [];
}
Expand Down
15 changes: 5 additions & 10 deletions app/Rules/ValidPhoneInputRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,16 @@ class ValidPhoneInputRule implements Rule
{
public function passes($attribute, $value)
{
if (!is_string($value)) {
if (!is_string($value) || !Str::startsWith($value, '+')) {
return false;
}
if (!Str::startsWith($value, '+')) {
return false;
}
$parts = explode(' ', $value);
if (count($parts) < 2) {
return false;
}
return strlen($parts[1]) >= 5;

$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
return $phoneUtil->isValidNumber($phoneUtil->parse($value));
}

public function message()
{
return 'The :attribute must be a string that starts with a "+" character and must be at least 5 digits long.';
return 'The :attribute is invalid.';
}
}
2 changes: 1 addition & 1 deletion app/Service/Forms/FormSubmissionFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function getCleanKeyValue()

// If hide hidden fields
if (!$this->showHiddenFields) {
if (FormLogicPropertyResolver::isHidden($field, $this->idFormData)) {
if (FormLogicPropertyResolver::isHidden($field, $this->idFormData ?? [])) {
continue;
}
}
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.2",
"ext-json": "*",
"aws/aws-sdk-php": "^3.183",
"doctrine/dbal": "^3.4",
"fruitcake/laravel-cors": "^2.0",
"giggsey/libphonenumber-for-php": "^8.13",
"guzzlehttp/guzzle": "^7.0.1",
"jhumanj/laravel-model-stats": "^0.4.0",
"laravel/cashier": "^13.4",
Expand Down
Loading

0 comments on commit b62d7ad

Please sign in to comment.