Pickles Framework Documentation

RequiredWith
in package
implements ValidationRule

Validation rule that checks if a field is required when another specified field is present.

This rule ensures that the field under validation is not empty if any of the specified fields are present in the input data.

Implements the ValidationRule interface to define custom validation logic.

Table of Contents

Interfaces

ValidationRule
Interface ValidationRule

Properties

$withField  : string

Methods

__construct()  : mixed
message()  : string
Returns the validation error message.
validate()  : bool
Validates that the given field and the specified "with" field both have content.

Properties

Methods

__construct()

public __construct(string $withField) : mixed
Parameters
$withField : string

message()

Returns the validation error message.

public message() : string
Tags
inheritDoc
Return values
string

The error message indicating the field must be a number.

validate()

Validates that the given field and the specified "with" field both have content.

public validate(string $field, array<string|int, mixed> $data) : bool
Parameters
$field : string

The name of the field to validate.

$data : array<string|int, mixed>

The data array containing the fields and their values.

Return values
bool

Returns true if both the field and the "with" field have content; otherwise, false.


        
On this page

Search results