Skip to content

Latest commit

 

History

History
1012 lines (676 loc) · 16.2 KB

validation-attributes.md

File metadata and controls

1012 lines (676 loc) · 16.2 KB
title weight
Validation attributes
14

These are all the validation attributes currently available in laravel-data.

Accepted

Docs

#[Accepted]
public bool $closure; 

AcceptedIf

Docs

#[AcceptedIf('other_field', 'equals_this')]
public bool $closure; 

ActiveUrl

Docs

#[ActiveUrl]
public string $closure; 

After

Docs

#[After('tomorrow')]
public Carbon $closure; 

#[After(Carbon::yesterday())]
public Carbon $closure; 

// Always use field references when referencing other fields
#[After(new FieldReference('other_field'))]
public Carbon $closure; 

AfterOrEqual

Docs

#[AfterOrEqual('tomorrow')]
public Carbon $closure; 

#[AfterOrEqual(Carbon::yesterday())]
public Carbon $closure; 

// Always use field references when referencing other fields
#[AfterOrEqual(new FieldReference('other_field'))]
public Carbon $closure; 

Alpha

Docs

#[Alpha]
public string $closure; 

AlphaDash

Docs

#[AlphaDash]
public string $closure; 

AlphaNumeric

Docs

#[AlphaNumeric]
public string $closure; 

ArrayType

Docs

#[ArrayType]
public array $closure; 

#[ArrayType(['valid_key', 'other_valid_key'])]
public array $closure; 

#[ArrayType('valid_key', 'other_valid_key')]
public array $closure; 

Bail

Docs

#[Bail]
public string $closure; 

Before

Docs

#[Before('tomorrow')]
public Carbon $closure; 

#[Before(Carbon::yesterday())]
public Carbon $closure; 

// Always use field references when referencing other fields
#[Before(new FieldReference('other_field'))]
public Carbon $closure; 

BeforeOrEqual

Docs

#[BeforeOrEqual('tomorrow')]
public Carbon $closure; 

#[BeforeOrEqual(Carbon::yesterday())]
public Carbon $closure; 

// Always use field references when referencing other fields
#[BeforeOrEqual(new FieldReference('other_field'))]
public Carbon $closure; 

Between

Docs

#[Between(3.14, 42)]
public int $closure; 

BooleanType

Docs

#[BooleanType]
public bool $closure; 

Confirmed

Docs

#[Confirmed]
public string $closure; 

CurrentPassword

Docs

#[CurrentPassword]
public string $closure; 

#[CurrentPassword('api')]
public string $closure; 

Date

Docs

#[Date]
public Carbon $date; 

DateEquals

Docs

#[DateEquals('tomorrow')]
public Carbon $date; 

#[DateEquals(Carbon::yesterday())]
public Carbon $date; 

DateFormat

Docs

#[DateFormat('d-m-Y')]
public Carbon $date;

#[DateFormat(['Y-m-d', 'Y-m-d H:i:s'])]
public Carbon $date;  

Declined

Docs

#[Declined]
public bool $closure; 

DeclinedIf

Docs

#[DeclinedIf('other_field', 'equals_this')]
public bool $closure; 

Different

Docs

#[Different('other_field')]
public string $closure; 

Digits

Docs

#[Digits(10)]
public int $closure; 

DigitsBetween

Docs

#[DigitsBetween(2, 10)]
public int $closure; 

Dimensions

Docs

#[Dimensions(ratio: 1.5)]
public UploadedFile $closure; 

#[Dimensions(maxWidth: 100, maxHeight: 100)]
public UploadedFile $closure; 

Distinct

Docs

#[Distinct]
public string $closure;

#[Distinct(Distinct::Strict)]
public string $closure;  

#[Distinct(Distinct::IgnoreCase)]
public string $closure;  

DoesntEndWith

Docs

#[DoesntEndWith('a')]
public string $closure;

#[DoesntEndWith(['a', 'b'])]
public string $closure;

#[DoesntEndWith('a', 'b')]
public string $closure;

DoesntStartWith

Docs

#[DoesntStartWith('a')]
public string $closure;

#[DoesntStartWith(['a', 'b'])]
public string $closure;

#[DoesntStartWith('a', 'b')]
public string $closure;

Email

Docs

#[Email]
public string $closure;

#[Email(Email::RfcValidation)]
public string $closure;  

#[Email([Email::RfcValidation, Email::DnsCheckValidation])]
public string $closure;  

#[Email(Email::RfcValidation, Email::DnsCheckValidation)]
public string $closure;  

EndsWith

Docs

#[EndsWith('a')]
public string $closure;

#[EndsWith(['a', 'b'])]
public string $closure;

#[EndsWith('a', 'b')]
public string $closure;

Enum

Docs

#[Enum(ChannelType::class)]
public string $closure;

ExcludeIf

At the moment the data is not yet excluded due to technical reasons, v4 should fix this

Docs

#[ExcludeIf('other_field', 'has_value')]
public string $closure;

ExcludeUnless

At the moment the data is not yet excluded due to technical reasons, v4 should fix this

Docs

#[ExcludeUnless('other_field', 'has_value')]
public string $closure;

ExcludeWith

At the moment the data is not yet excluded due to technical reasons, v4 should fix this

Docs

#[ExcludeWith('other_field')]
public string $closure;

ExcludeWithout

At the moment the data is not yet excluded due to technical reasons, v4 should fix this

Docs

#[ExcludeWithout('other_field')]
public string $closure;

Exists

Docs

#[Exists('users')]
public string $closure; 

#[Exists(User::class)]
public string $closure; 

#[Exists('users', 'email')]
public string $closure;

#[Exists('users', 'email', connection: 'tenant')]
public string $closure;

#[Exists('users', 'email', withoutTrashed: true)]
public string $closure;

File

Docs

#[File]
public UploadedFile $closure; 

Filled

Docs

#[Filled]
public string $closure; 

GreaterThan

Docs

#[GreaterThan('other_field')]
public int $closure; 

GreaterThanOrEqualTo

Docs

#[GreaterThanOrEqualTo('other_field')]
public int $closure; 

Image

Docs

#[Image]
public UploadedFile $closure; 

In

Docs

#[In([1, 2, 3, 'a', 'b'])]
public mixed $closure; 

#[In(1, 2, 3, 'a', 'b')]
public mixed $closure; 

InArray

Docs

#[InArray('other_field')]
public string $closure; 

IntegerType

Docs

#[IntegerType]
public int $closure; 

IP

Docs

#[IP]
public string $closure; 

IPv4

Docs

#[IPv4]
public string $closure; 

IPv6

Docs

#[IPv6]
public string $closure; 

Json

Docs

#[Json]
public string $closure; 

LessThan

Docs

#[LessThan('other_field')]
public int $closure; 

LessThanOrEqualTo

Docs

#[LessThanOrEqualTo('other_field')]
public int $closure; 

Lowercase

Docs

#[Lowercase]
public string $closure; 

ListType

Docs

#[ListType]
public array $array; 

MacAddress

Docs

#[MacAddress]
public string $closure; 

Max

Docs

#[Max(20)]
public int $closure; 

MaxDigits

Docs

#[MaxDigits(10)]
public int $closure; 

MimeTypes

Docs

#[MimeTypes('video/quicktime')]
public UploadedFile $closure; 

#[MimeTypes(['video/quicktime', 'video/avi'])]
public UploadedFile $closure; 

#[MimeTypes('video/quicktime', 'video/avi')]
public UploadedFile $closure; 

Mimes

Docs

#[Mimes('jpg')]
public UploadedFile $closure; 

#[Mimes(['jpg', 'png'])]
public UploadedFile $closure; 

#[Mimes('jpg', 'png')]
public UploadedFile $closure; 

Min

Docs

#[Min(20)]
public int $closure; 

MinDigits

Docs

#[MinDigits(2)]
public int $closure; 

MultipleOf

Docs

#[MultipleOf(3)]
public int $closure; 

NotIn

Docs

#[NotIn([1, 2, 3, 'a', 'b'])]
public mixed $closure; 

#[NotIn(1, 2, 3, 'a', 'b')]
public mixed $closure; 

NotRegex

Docs

#[NotRegex('/^.+$/i')]
public string $closure; 

Nullable

Docs

#[Nullable]
public ?string $closure; 

Numeric

Docs

#[Numeric]
public ?string $closure; 

Password

Docs

#[Password(min: 12, letters: true, mixedCase: true, numbers: false, symbols: false, uncompromised: true, uncompromisedThreshold: 0)]
public string $closure; 

Present

Docs

#[Present]
public string $closure; 

Prohibited

Docs

#[Prohibited]
public ?string $closure; 

ProhibitedIf

Docs

#[ProhibitedIf('other_field', 'has_value')]
public ?string $closure; 

#[ProhibitedIf('other_field', ['has_value', 'or_this_value'])]
public ?string $closure; 

ProhibitedUnless

Docs

#[ProhibitedUnless('other_field', 'has_value')]
public ?string $closure; 

#[ProhibitedUnless('other_field', ['has_value', 'or_this_value'])]
public ?string $closure; 

Prohibits

Docs

#[Prohibits('other_field')]
public ?string $closure; 

#[Prohibits(['other_field', 'another_field'])]
public ?string $closure; 

#[Prohibits('other_field', 'another_field')]
public ?string $closure; 

Regex

Docs

#[Regex('/^.+$/i')]
public string $closure; 

Required

Docs

#[Required]
public string $closure; 

RequiredIf

Docs

#[RequiredIf('other_field', 'value')]
public ?string $closure; 

#[RequiredIf('other_field', ['value', 'another_value'])]
public ?string $closure; 

RequiredUnless

Docs

#[RequiredUnless('other_field', 'value')]
public ?string $closure; 

#[RequiredUnless('other_field', ['value', 'another_value'])]
public ?string $closure; 

RequiredWith

Docs

#[RequiredWith('other_field')]
public ?string $closure; 

#[RequiredWith(['other_field', 'another_field'])]
public ?string $closure; 

#[RequiredWith('other_field', 'another_field')]
public ?string $closure; 

RequiredWithAll

Docs

#[RequiredWithAll('other_field')]
public ?string $closure; 

#[RequiredWithAll(['other_field', 'another_field'])]
public ?string $closure; 

#[RequiredWithAll('other_field', 'another_field')]
public ?string $closure; 

RequiredWithout

Docs

#[RequiredWithout('other_field')]
public ?string $closure; 

#[RequiredWithout(['other_field', 'another_field'])]
public ?string $closure; 

#[RequiredWithout('other_field', 'another_field')]
public ?string $closure; 

RequiredWithoutAll

Docs

#[RequiredWithoutAll('other_field')]
public ?string $closure; 

#[RequiredWithoutAll(['other_field', 'another_field'])]
public ?string $closure; 

#[RequiredWithoutAll('other_field', 'another_field')]
public ?string $closure; 

RequiredArrayKeys

Docs

#[RequiredArrayKeys('a')]
public array $closure;

#[RequiredArrayKeys(['a', 'b'])]
public array $closure;

#[RequiredArrayKeys('a', 'b')]
public array $closure;

Rule

#[Rule('string|uuid')]
public string $closure; 

#[Rule(['string','uuid'])]
public string $closure; 

Same

Docs

#[Same('other_field')]
public string $closure; 

Size

Docs

#[Size(10)]
public string $closure; 

Sometimes

Docs

#[Sometimes]
public string $closure; 

StartsWith

Docs

#[StartsWith('a')]
public string $closure;

#[StartsWith(['a', 'b'])]
public string $closure;

#[StartsWith('a', 'b')]
public string $closure;

StringType

Docs

#[StringType()]
public string $closure; 

TimeZone

Docs

#[TimeZone()]
public string $closure; 

Unique

Docs

#[Unique('users')]
public string $closure; 

#[Unique(User::class)]
public string $closure; 

#[Unique('users', 'email')]
public string $closure;

#[Unique('users', connection: 'tenant')]
public string $closure;

#[Unique('users', withoutTrashed: true)]
public string $closure;

#[Unique('users', ignore: 5)]
public string $closure;

Uppercase

Docs

#[Uppercase]
public string $closure; 

Url

Docs

#[Url]
public string $closure; 

Ulid

Docs

#[Ulid]
public string $closure; 

Uuid

Docs

#[Uuid]
public string $closure;