Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
UserAdminV2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
庄欣
UserAdminV2
Commits
554d390f
Commit
554d390f
authored
Feb 03, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added same and different validation rules.
parent
d462a729
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
4 deletions
+36
-4
application/language/en/validation.php
+2
-0
laravel/validator.php
+34
-4
No files found.
application/language/en/validation.php
View file @
554d390f
...
@@ -29,6 +29,7 @@ return array(
...
@@ -29,6 +29,7 @@ return array(
"string"
=>
"The :attribute must be between :min - :max characters."
,
"string"
=>
"The :attribute must be between :min - :max characters."
,
),
),
"confirmed"
=>
"The :attribute confirmation does not match."
,
"confirmed"
=>
"The :attribute confirmation does not match."
,
"different"
=>
"The :attribute and :other must be different."
,
"email"
=>
"The :attribute format is invalid."
,
"email"
=>
"The :attribute format is invalid."
,
"exists"
=>
"The selected :attribute is invalid."
,
"exists"
=>
"The selected :attribute is invalid."
,
"image"
=>
"The :attribute must be an image."
,
"image"
=>
"The :attribute must be an image."
,
...
@@ -49,6 +50,7 @@ return array(
...
@@ -49,6 +50,7 @@ return array(
"not_in"
=>
"The selected :attribute is invalid."
,
"not_in"
=>
"The selected :attribute is invalid."
,
"numeric"
=>
"The :attribute must be a number."
,
"numeric"
=>
"The :attribute must be a number."
,
"required"
=>
"The :attribute field is required."
,
"required"
=>
"The :attribute field is required."
,
"same"
=>
"The :attribute and :other must match."
,
"size"
=>
array
(
"size"
=>
array
(
"numeric"
=>
"The :attribute must be :size."
,
"numeric"
=>
"The :attribute must be :size."
,
"file"
=>
"The :attribute must be :size kilobyte."
,
"file"
=>
"The :attribute must be :size kilobyte."
,
...
...
laravel/validator.php
View file @
554d390f
...
@@ -253,9 +253,7 @@ class Validator {
...
@@ -253,9 +253,7 @@ class Validator {
*/
*/
protected
function
validate_confirmed
(
$attribute
,
$value
)
protected
function
validate_confirmed
(
$attribute
,
$value
)
{
{
$confirmed
=
$attribute
.
'_confirmation'
;
return
$this
->
validate_same
(
$attribute
,
$value
,
array
(
$attribute
.
'_confirmation'
));
return
isset
(
$this
->
attributes
[
$confirmed
])
and
$value
==
$this
->
attributes
[
$confirmed
];
}
}
/**
/**
...
@@ -273,6 +271,36 @@ class Validator {
...
@@ -273,6 +271,36 @@ class Validator {
}
}
/**
/**
* Validate that an attribute is the same as another attribute.
*
* @param string $attribute
* @param mixed $value
* @param array $parameters
* @return bool
*/
protected
function
validate_same
(
$attribute
,
$value
,
$parameters
)
{
$other
=
$parameters
[
0
];
return
isset
(
$this
->
attributes
[
$other
])
and
$value
==
$this
->
attributes
[
$other
];
}
/**
* Validate that an attribute is different from another attribute.
*
* @param string $attribute
* @param mixed $value
* @param array $parameters
* @return bool
*/
protected
function
validate_different
(
$attribute
,
$value
,
$parameters
)
{
$other
=
$parameters
[
0
];
return
isset
(
$this
->
attributes
[
$other
])
and
$value
!=
$this
->
attributes
[
$other
];
}
/**
* Validate that an attribute is numeric.
* Validate that an attribute is numeric.
*
*
* @param string $attribute
* @param string $attribute
...
@@ -727,7 +755,9 @@ class Validator {
...
@@ -727,7 +755,9 @@ class Validator {
// If no language line has been specified for the attribute, all of
// If no language line has been specified for the attribute, all of
// the underscores will be removed from the attribute name and that
// the underscores will be removed from the attribute name and that
// will be used as the attribtue name in the message.
// will be used as the attribtue name in the message.
$display
=
Lang
::
line
(
"
{
$bundle
}
validation.attributes.
{
$attribute
}
"
)
->
get
(
$this
->
language
);
$line
=
"
{
$bundle
}
validation.attributes.
{
$attribute
}
"
;
$display
=
Lang
::
line
(
$line
)
->
get
(
$this
->
language
);
return
(
is_null
(
$display
))
?
str_replace
(
'_'
,
' '
,
$attribute
)
:
$display
;
return
(
is_null
(
$display
))
?
str_replace
(
'_'
,
' '
,
$attribute
)
:
$display
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment