Uname: Linux webm012.cluster130.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 8.0.30 [ PHP INFO ] PHP os: Linux
Server Ip: 145.239.37.162
Your Ip: 216.73.216.190
User: dreampi (1009562) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : Notifications.php
<?php

namespace FluentForm\App\Services\Settings\Validator;

use FluentForm\Framework\Helpers\ArrayHelper;
use FluentForm\Framework\Validator\Validator;

class Notifications extends Validate
{
    /**
     * Produce the necessary validation rules and corresponding messages
     *
     * @return array
     */
    public static function validations()
    {
        return [
            [
                'sendTo.type'    => 'required',
                'sendTo.email'   => 'required_if:sendTo.type,email',
                'sendTo.field'   => 'required_if:sendTo.type,field',
                'sendTo.routing' => 'required_if:sendTo.type,routing',
                'subject'        => 'required',
                'message'        => 'required',
            ],
            [
                'sendTo.type.required'     => 'The Send To field is required.',
                'sendTo.email.required_if' => 'The Send to Email field is required.',
                'sendTo.field.required_if' => 'The Send to Field field is required.',
                'sendTo.routing'           => 'Please fill all the routing rules above.',
            ],
        ];
    }

    /**
     * Add conditional validations to the validator.
     *
     * @param \FluentForm\Framework\Validator\Validator $validator
     *
     * @return \FluentForm\Framework\Validator\Validator
     */
    public static function conditionalValidations(Validator $validator)
    {
        $validator->sometimes('sendTo.routing', 'required', function ($input) {
            if ('routing' !== ArrayHelper::get($input, 'sendTo.type')) {
                return false;
            }

            $routingInputs = ArrayHelper::get($input, 'sendTo.routing');
            $required = false;

            foreach ($routingInputs as $routingInput) {
                if (!$routingInput['input_value'] || !$routingInput['field']) {
                    $required = true;
                    break;
                }
            }

            return $required;
        });

        return $validator;
    }
}
© 2026 GrazzMean-Shell