What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hi there, I have problem with a middleware ValidationRuleSet ```/** * @return array */ protected

U019D1B44E8
U019D1B44E8 Posts: 5 🧑🏻‍🚀 - Cadet

Hi there, I have problem with a middleware ValidationRuleSet

/**
 * @return array
 */
protected function getRules(): array
{
    return [
        'meta_info.errcode' => [
            ['EqualTo', 'options' => ['value' => AgErpConstants::AG_ERP_NO_ERROR]],
        ],
        'meta_info.aes' => [
            ['InList', 'options' => ['values' => [AgErpConstants::AG_ERP_AES_STATUS_NEW, AgErpConstants::AG_ERP_AES_STATUS_UPDATE]]],
        ],
        'konto' => 'NotBlank',
        'address' => ['Type', 'options' => ['type' => 'array']],
    ];
}

the TypeValidator for "address" complains (throws an exception) that no required options are provided. I am using 'options' => ['type' => 'array']
What I want to do is to check if address is of type array

Would appreciate your help.

Comments

  • U013EK8RD7A
    U013EK8RD7A Posts: 127 🧑🏻‍🚀 - Cadet

    I think you have to nest it:

    'address' => [
        ['Type', 'options' => ['type' => 'array']],
        ];
    
  • U019D1B44E8
    U019D1B44E8 Posts: 5 🧑🏻‍🚀 - Cadet

    Hi Paulius, you were right. Thanks a lot.