Skip to content

Validation Exceptions #412

Description

@SmolSoftBoi

Validation throws an exception for alpha_dash and is_natural_no_zero rules (and likely other rules) when a null value is passed, but should allow null as the value.

Also throws an exception for required_without when an array value is passed, but should allow array values.

Example:

$data = [
    'eventId' => '1',
    'donationPrice' => '2',
    'charityKey' => 'samaritans',
    'user' => [
        'firstName' => 'Kristian',
        'lastName' => 'Matthews',
        'email' => 'guest@me.com',
        'phone' => '',
    ],
    'tickets' => [
        [
            'name' => 'Guest 1',
            'allergies' => '',
        ],
        [
            'name' => 'Guest 2',
            'allergies' => '',
        ],
    ],
    'card' => [
        'paymentProcessorKey' => 'stripe',
        'thirdPartyCardId' => 'tok_…',
    ],
]

$rules = [
    'eventId'       => 'required_without[eventKey]|is_natural_no_zero',
    'eventKey'      => 'required_without[eventId]|alpha_dash',
    'paymentId'     => 'required_without[card]|is_natural_no_zero',
    'charityId'     => 'required_without[charityKey]|is_natural_no_zero',
    'charityKey'    => 'required_without[charityId]|alpha_dash',
    'userId'        => 'required_without[user]|is_natural_no_zero',
    'donationPrice' => 'decimal|greater_than_equal_to[0]',
    'card'          => 'required_without[paymentId]',
    'user'          => 'required_without[userId]'
]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions