company_key = $company_key; $this->isEnterprise = $isEnterprise; } public function passes($attribute, $value) { if (empty($value)) { return true; } // early return, if we dont have any additional validation if (!config('ninja.inbound_expense.webhook.mailbox_schema') && !(Ninja::isHosted() && config('ninja.inbound_expense.webhook.mailbox_schema_enterprise'))) { $this->validated_schema = true; return MultiDB::checkExpenseMailboxAvailable($value); } // Validate Schema $validated = !config('ninja.inbound_expense.webhook.mailbox_schema') || (preg_match(config('ninja.inbound_expense.webhook.mailbox_schema'), $value) && (!config('ninja.inbound_expense.webhook.mailbox_schema_hascompanykey') || str_contains($value, $this->company_key))) ? true : false; $validated_enterprise = !config('ninja.inbound_expense.webhook.mailbox_schema_enterprise') || (Ninja::isHosted() && $this->isEnterprise && preg_match(config('ninja.inbound_expense.webhook.mailbox_schema_enterprise'), $value)); if (!$validated && !$validated_enterprise) return false; $this->validated_schema = true; return MultiDB::checkExpenseMailboxAvailable($value); } /** * @return string */ public function message() { return $this->validated_schema ? ctrans('texts.expense_mailbox_taken') : ctrans('texts.expense_mailbox_invalid'); } }