forked from illuminate/validation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRule.php
76 lines (66 loc) · 1.85 KB
/
Rule.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
namespace Illuminate\Validation;
use Illuminate\Support\Collection;
use Illuminate\Support\Traits\Macroable;
class Rule
{
use Macroable;
/**
* Get a dimensions constraint builder instance.
*
* @param array $constraints
* @return \Illuminate\Validation\Rules\Dimensions
*/
public static function dimensions(array $constraints = [])
{
return new Rules\Dimensions($constraints);
}
/**
* Get a exists constraint builder instance.
*
* @param string $table
* @param string $column
* @return \Illuminate\Validation\Rules\Exists
*/
public static function exists($table, $column = 'NULL')
{
return new Rules\Exists($table, $column);
}
/**
* Get an in constraint builder instance.
*
* @param array|string|\Illuminate\Support\Collection $values
* @return \Illuminate\Validation\Rules\In
*/
public static function in($values)
{
if ($values instanceof Collection) {
$values = $values->toArray();
}
return new Rules\In(is_array($values) ? $values : func_get_args());
}
/**
* Get a not_in constraint builder instance.
*
* @param array|string|\Illuminate\Support\Collection $values
* @return \Illuminate\Validation\Rules\NotIn
*/
public static function notIn($values)
{
if ($values instanceof Collection) {
$values = $values->toArray();
}
return new Rules\NotIn(is_array($values) ? $values : func_get_args());
}
/**
* Get a unique constraint builder instance.
*
* @param string $table
* @param string $column
* @return \Illuminate\Validation\Rules\Unique
*/
public static function unique($table, $column = 'NULL')
{
return new Rules\Unique($table, $column);
}
}