respect-validation/docs/Sorted.md
Mikhail Vyrtsev 52c8541b9e New rule: Sorted
2017-06-29 05:18:02 +03:00

632 B

Ordered

  • Sorted(callable $fn = null, bool $ascending = true)

Validates if the input is Sorted

v::sorted()->validate([1,2,3]); // true
v::sorted()->validate([1,6,3]); // false
v::sorted(null, false)->validate([3,2,1]); // true
v::sorted(function($x){
	return $x['key'];
})->validate([
	[
		'key' => 1,
	],
	[
		'key' => 5,
	],
	[
		'key' => 9,
	],
]); // true
v::sorted(function($x){
	return $x['key'];
})->validate([
	[
		'key' => 1,
	],
	[
		'key' => 4,
	],
	[
		'key' => 7,
	],
]); // false

Changelog

Version Description
1.1.1 Created

See also: