Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
266f4f98
Commit
266f4f98
authored
Oct 14, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clientvalidation {value} was not what has been validated
also fixed some inconsistency between client and server validation.
parent
8899aaeb
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
24 additions
and
31 deletions
+24
-31
yii.validation.js
framework/yii/assets/yii.validation.js
+22
-15
BooleanValidator.php
framework/yii/validators/BooleanValidator.php
+0
-1
CompareValidator.php
framework/yii/validators/CompareValidator.php
+2
-1
EmailValidator.php
framework/yii/validators/EmailValidator.php
+0
-1
NumberValidator.php
framework/yii/validators/NumberValidator.php
+0
-4
RangeValidator.php
framework/yii/validators/RangeValidator.php
+0
-1
RegularExpressionValidator.php
framework/yii/validators/RegularExpressionValidator.php
+0
-1
RequiredValidator.php
framework/yii/validators/RequiredValidator.php
+0
-1
StringValidator.php
framework/yii/validators/StringValidator.php
+0
-5
UrlValidator.php
framework/yii/validators/UrlValidator.php
+0
-1
No files found.
framework/yii/assets/yii.validation.js
View file @
266f4f98
...
@@ -16,6 +16,10 @@ yii.validation = (function ($) {
...
@@ -16,6 +16,10 @@ yii.validation = (function ($) {
||
value
===
''
||
trim
&&
$
.
trim
(
value
)
===
''
;
||
value
===
''
||
trim
&&
$
.
trim
(
value
)
===
''
;
};
};
var
addMessage
=
function
(
messages
,
message
,
value
)
{
messages
.
push
(
message
.
replace
(
/
\{
value
\}
/g
,
value
));
};
return
{
return
{
required
:
function
(
value
,
messages
,
options
)
{
required
:
function
(
value
,
messages
,
options
)
{
var
valid
=
false
;
var
valid
=
false
;
...
@@ -28,7 +32,7 @@ yii.validation = (function ($) {
...
@@ -28,7 +32,7 @@ yii.validation = (function ($) {
}
}
if
(
!
valid
)
{
if
(
!
valid
)
{
messages
.
push
(
options
.
messag
e
);
addMessage
(
messages
,
options
.
message
,
valu
e
);
}
}
},
},
...
@@ -40,7 +44,7 @@ yii.validation = (function ($) {
...
@@ -40,7 +44,7 @@ yii.validation = (function ($) {
||
options
.
strict
&&
(
value
===
options
.
trueValue
||
value
===
options
.
falseValue
);
||
options
.
strict
&&
(
value
===
options
.
trueValue
||
value
===
options
.
falseValue
);
if
(
!
valid
)
{
if
(
!
valid
)
{
messages
.
push
(
options
.
messag
e
);
addMessage
(
messages
,
options
.
message
,
valu
e
);
}
}
},
},
...
@@ -50,18 +54,18 @@ yii.validation = (function ($) {
...
@@ -50,18 +54,18 @@ yii.validation = (function ($) {
}
}
if
(
typeof
value
!==
'string'
)
{
if
(
typeof
value
!==
'string'
)
{
messages
.
push
(
options
.
messag
e
);
addMessage
(
messages
,
options
.
message
,
valu
e
);
return
;
return
;
}
}
if
(
options
.
min
!==
undefined
&&
value
.
length
<
options
.
min
)
{
if
(
options
.
min
!==
undefined
&&
value
.
length
<
options
.
min
)
{
messages
.
push
(
options
.
tooShort
);
addMessage
(
messages
,
options
.
tooShort
,
value
);
}
}
if
(
options
.
max
!==
undefined
&&
value
.
length
>
options
.
max
)
{
if
(
options
.
max
!==
undefined
&&
value
.
length
>
options
.
max
)
{
messages
.
push
(
options
.
tooLong
);
addMessage
(
messages
,
options
.
tooLong
,
value
);
}
}
if
(
options
.
is
!==
undefined
&&
value
.
length
!=
options
.
is
)
{
if
(
options
.
is
!==
undefined
&&
value
.
length
!=
options
.
is
)
{
messages
.
push
(
options
.
is
);
addMessage
(
messages
,
options
.
is
,
value
);
}
}
},
},
...
@@ -71,15 +75,15 @@ yii.validation = (function ($) {
...
@@ -71,15 +75,15 @@ yii.validation = (function ($) {
}
}
if
(
typeof
value
===
'string'
&&
!
value
.
match
(
options
.
pattern
))
{
if
(
typeof
value
===
'string'
&&
!
value
.
match
(
options
.
pattern
))
{
messages
.
push
(
options
.
messag
e
);
addMessage
(
messages
,
options
.
message
,
valu
e
);
return
;
return
;
}
}
if
(
options
.
min
!==
undefined
&&
value
<
options
.
min
)
{
if
(
options
.
min
!==
undefined
&&
value
<
options
.
min
)
{
messages
.
push
(
options
.
tooSmall
);
addMessage
(
messages
,
options
.
tooSmall
,
value
);
}
}
if
(
options
.
max
!==
undefined
&&
value
>
options
.
max
)
{
if
(
options
.
max
!==
undefined
&&
value
>
options
.
max
)
{
messages
.
push
(
options
.
tooBig
);
addMessage
(
messages
,
options
.
tooBig
,
value
);
}
}
},
},
...
@@ -91,7 +95,7 @@ yii.validation = (function ($) {
...
@@ -91,7 +95,7 @@ yii.validation = (function ($) {
||
options
.
not
&&
$
.
inArray
(
value
,
options
.
range
)
==
-
1
;
||
options
.
not
&&
$
.
inArray
(
value
,
options
.
range
)
==
-
1
;
if
(
!
valid
)
{
if
(
!
valid
)
{
messages
.
push
(
options
.
messag
e
);
addMessage
(
messages
,
options
.
message
,
valu
e
);
}
}
},
},
...
@@ -101,7 +105,7 @@ yii.validation = (function ($) {
...
@@ -101,7 +105,7 @@ yii.validation = (function ($) {
}
}
if
(
!
options
.
not
&&
!
value
.
match
(
options
.
pattern
)
||
options
.
not
&&
value
.
match
(
options
.
pattern
))
{
if
(
!
options
.
not
&&
!
value
.
match
(
options
.
pattern
)
||
options
.
not
&&
value
.
match
(
options
.
pattern
))
{
messages
.
push
(
options
.
message
)
addMessage
(
messages
,
options
.
message
,
value
);
}
}
},
},
...
@@ -123,7 +127,7 @@ yii.validation = (function ($) {
...
@@ -123,7 +127,7 @@ yii.validation = (function ($) {
}
}
if
(
!
valid
||
!
(
value
.
match
(
options
.
pattern
)
&&
(
!
options
.
allowName
||
value
.
match
(
options
.
fullPattern
))))
{
if
(
!
valid
||
!
(
value
.
match
(
options
.
pattern
)
&&
(
!
options
.
allowName
||
value
.
match
(
options
.
fullPattern
))))
{
messages
.
push
(
options
.
messag
e
);
addMessage
(
messages
,
options
.
message
,
valu
e
);
}
}
},
},
...
@@ -149,7 +153,7 @@ yii.validation = (function ($) {
...
@@ -149,7 +153,7 @@ yii.validation = (function ($) {
}
}
if
(
!
valid
||
!
value
.
match
(
options
.
pattern
))
{
if
(
!
valid
||
!
value
.
match
(
options
.
pattern
))
{
messages
.
push
(
options
.
messag
e
);
addMessage
(
messages
,
options
.
message
,
valu
e
);
}
}
},
},
...
@@ -170,7 +174,7 @@ yii.validation = (function ($) {
...
@@ -170,7 +174,7 @@ yii.validation = (function ($) {
h
+=
v
.
charCodeAt
(
i
);
h
+=
v
.
charCodeAt
(
i
);
}
}
if
(
h
!=
hash
)
{
if
(
h
!=
hash
)
{
messages
.
push
(
options
.
messag
e
);
addMessage
(
messages
,
options
.
message
,
valu
e
);
}
}
},
},
...
@@ -210,10 +214,13 @@ yii.validation = (function ($) {
...
@@ -210,10 +214,13 @@ yii.validation = (function ($) {
case
'<='
:
case
'<='
:
valid
=
value
<=
compareValue
;
valid
=
value
<=
compareValue
;
break
;
break
;
default
:
valid
=
false
;
break
;
}
}
if
(
!
valid
)
{
if
(
!
valid
)
{
messages
.
push
(
options
.
messag
e
);
addMessage
(
messages
,
options
.
message
,
valu
e
);
}
}
}
}
};
};
...
...
framework/yii/validators/BooleanValidator.php
View file @
266f4f98
...
@@ -90,7 +90,6 @@ class BooleanValidator extends Validator
...
@@ -90,7 +90,6 @@ class BooleanValidator extends Validator
'falseValue'
=>
$this
->
falseValue
,
'falseValue'
=>
$this
->
falseValue
,
'message'
=>
Html
::
encode
(
strtr
(
$this
->
message
,
array
(
'message'
=>
Html
::
encode
(
strtr
(
$this
->
message
,
array
(
'{attribute}'
=>
$object
->
getAttributeLabel
(
$attribute
),
'{attribute}'
=>
$object
->
getAttributeLabel
(
$attribute
),
'{value}'
=>
$object
->
$attribute
,
'{true}'
=>
$this
->
trueValue
,
'{true}'
=>
$this
->
trueValue
,
'{false}'
=>
$this
->
falseValue
,
'{false}'
=>
$this
->
falseValue
,
))),
))),
...
...
framework/yii/validators/CompareValidator.php
View file @
266f4f98
...
@@ -170,6 +170,7 @@ class CompareValidator extends Validator
...
@@ -170,6 +170,7 @@ class CompareValidator extends Validator
case
'>='
:
return
$value
>=
$this
->
compareValue
;
case
'>='
:
return
$value
>=
$this
->
compareValue
;
case
'<'
:
return
$value
<
$this
->
compareValue
;
case
'<'
:
return
$value
<
$this
->
compareValue
;
case
'<='
:
return
$value
<=
$this
->
compareValue
;
case
'<='
:
return
$value
<=
$this
->
compareValue
;
default
:
return
false
;
}
}
}
}
...
@@ -201,7 +202,7 @@ class CompareValidator extends Validator
...
@@ -201,7 +202,7 @@ class CompareValidator extends Validator
$options
[
'message'
]
=
Html
::
encode
(
strtr
(
$this
->
message
,
array
(
$options
[
'message'
]
=
Html
::
encode
(
strtr
(
$this
->
message
,
array
(
'{attribute}'
=>
$object
->
getAttributeLabel
(
$attribute
),
'{attribute}'
=>
$object
->
getAttributeLabel
(
$attribute
),
'{
value}'
=>
$object
->
$attribut
e
,
'{
compareAttribute}'
=>
$compareValu
e
,
'{compareValue}'
=>
$compareValue
,
'{compareValue}'
=>
$compareValue
,
)));
)));
...
...
framework/yii/validators/EmailValidator.php
View file @
266f4f98
...
@@ -131,7 +131,6 @@ class EmailValidator extends Validator
...
@@ -131,7 +131,6 @@ class EmailValidator extends Validator
'allowName'
=>
$this
->
allowName
,
'allowName'
=>
$this
->
allowName
,
'message'
=>
Html
::
encode
(
strtr
(
$this
->
message
,
array
(
'message'
=>
Html
::
encode
(
strtr
(
$this
->
message
,
array
(
'{attribute}'
=>
$object
->
getAttributeLabel
(
$attribute
),
'{attribute}'
=>
$object
->
getAttributeLabel
(
$attribute
),
'{value}'
=>
$object
->
$attribute
,
))),
))),
'enableIDN'
=>
(
boolean
)
$this
->
enableIDN
,
'enableIDN'
=>
(
boolean
)
$this
->
enableIDN
,
);
);
...
...
framework/yii/validators/NumberValidator.php
View file @
266f4f98
...
@@ -121,13 +121,11 @@ class NumberValidator extends Validator
...
@@ -121,13 +121,11 @@ class NumberValidator extends Validator
public
function
clientValidateAttribute
(
$object
,
$attribute
,
$view
)
public
function
clientValidateAttribute
(
$object
,
$attribute
,
$view
)
{
{
$label
=
$object
->
getAttributeLabel
(
$attribute
);
$label
=
$object
->
getAttributeLabel
(
$attribute
);
$value
=
$object
->
$attribute
;
$options
=
array
(
$options
=
array
(
'pattern'
=>
new
JsExpression
(
$this
->
integerOnly
?
$this
->
integerPattern
:
$this
->
numberPattern
),
'pattern'
=>
new
JsExpression
(
$this
->
integerOnly
?
$this
->
integerPattern
:
$this
->
numberPattern
),
'message'
=>
Html
::
encode
(
strtr
(
$this
->
message
,
array
(
'message'
=>
Html
::
encode
(
strtr
(
$this
->
message
,
array
(
'{attribute}'
=>
$label
,
'{attribute}'
=>
$label
,
'{value}'
=>
$value
,
))),
))),
);
);
...
@@ -135,7 +133,6 @@ class NumberValidator extends Validator
...
@@ -135,7 +133,6 @@ class NumberValidator extends Validator
$options
[
'min'
]
=
$this
->
min
;
$options
[
'min'
]
=
$this
->
min
;
$options
[
'tooSmall'
]
=
Html
::
encode
(
strtr
(
$this
->
tooSmall
,
array
(
$options
[
'tooSmall'
]
=
Html
::
encode
(
strtr
(
$this
->
tooSmall
,
array
(
'{attribute}'
=>
$label
,
'{attribute}'
=>
$label
,
'{value}'
=>
$value
,
'{min}'
=>
$this
->
min
,
'{min}'
=>
$this
->
min
,
)));
)));
}
}
...
@@ -143,7 +140,6 @@ class NumberValidator extends Validator
...
@@ -143,7 +140,6 @@ class NumberValidator extends Validator
$options
[
'max'
]
=
$this
->
max
;
$options
[
'max'
]
=
$this
->
max
;
$options
[
'tooBig'
]
=
Html
::
encode
(
strtr
(
$this
->
tooBig
,
array
(
$options
[
'tooBig'
]
=
Html
::
encode
(
strtr
(
$this
->
tooBig
,
array
(
'{attribute}'
=>
$label
,
'{attribute}'
=>
$label
,
'{value}'
=>
$value
,
'{max}'
=>
$this
->
max
,
'{max}'
=>
$this
->
max
,
)));
)));
}
}
...
...
framework/yii/validators/RangeValidator.php
View file @
266f4f98
...
@@ -96,7 +96,6 @@ class RangeValidator extends Validator
...
@@ -96,7 +96,6 @@ class RangeValidator extends Validator
'not'
=>
$this
->
not
,
'not'
=>
$this
->
not
,
'message'
=>
Html
::
encode
(
strtr
(
$this
->
message
,
array
(
'message'
=>
Html
::
encode
(
strtr
(
$this
->
message
,
array
(
'{attribute}'
=>
$object
->
getAttributeLabel
(
$attribute
),
'{attribute}'
=>
$object
->
getAttributeLabel
(
$attribute
),
'{value}'
=>
$object
->
$attribute
,
))),
))),
);
);
if
(
$this
->
skipOnEmpty
)
{
if
(
$this
->
skipOnEmpty
)
{
...
...
framework/yii/validators/RegularExpressionValidator.php
View file @
266f4f98
...
@@ -103,7 +103,6 @@ class RegularExpressionValidator extends Validator
...
@@ -103,7 +103,6 @@ class RegularExpressionValidator extends Validator
'not'
=>
$this
->
not
,
'not'
=>
$this
->
not
,
'message'
=>
Html
::
encode
(
strtr
(
$this
->
message
,
array
(
'message'
=>
Html
::
encode
(
strtr
(
$this
->
message
,
array
(
'{attribute}'
=>
$object
->
getAttributeLabel
(
$attribute
),
'{attribute}'
=>
$object
->
getAttributeLabel
(
$attribute
),
'{value}'
=>
$object
->
$attribute
,
))),
))),
);
);
if
(
$this
->
skipOnEmpty
)
{
if
(
$this
->
skipOnEmpty
)
{
...
...
framework/yii/validators/RequiredValidator.php
View file @
266f4f98
...
@@ -123,7 +123,6 @@ class RequiredValidator extends Validator
...
@@ -123,7 +123,6 @@ class RequiredValidator extends Validator
$options
[
'message'
]
=
Html
::
encode
(
strtr
(
$options
[
'message'
],
array
(
$options
[
'message'
]
=
Html
::
encode
(
strtr
(
$options
[
'message'
],
array
(
'{attribute}'
=>
$object
->
getAttributeLabel
(
$attribute
),
'{attribute}'
=>
$object
->
getAttributeLabel
(
$attribute
),
'{value}'
=>
$object
->
$attribute
,
)));
)));
ValidationAsset
::
register
(
$view
);
ValidationAsset
::
register
(
$view
);
...
...
framework/yii/validators/StringValidator.php
View file @
266f4f98
...
@@ -149,12 +149,10 @@ class StringValidator extends Validator
...
@@ -149,12 +149,10 @@ class StringValidator extends Validator
public
function
clientValidateAttribute
(
$object
,
$attribute
,
$view
)
public
function
clientValidateAttribute
(
$object
,
$attribute
,
$view
)
{
{
$label
=
$object
->
getAttributeLabel
(
$attribute
);
$label
=
$object
->
getAttributeLabel
(
$attribute
);
$value
=
$object
->
$attribute
;
$options
=
array
(
$options
=
array
(
'message'
=>
Html
::
encode
(
strtr
(
$this
->
message
,
array
(
'message'
=>
Html
::
encode
(
strtr
(
$this
->
message
,
array
(
'{attribute}'
=>
$label
,
'{attribute}'
=>
$label
,
'{value}'
=>
$value
,
))),
))),
);
);
...
@@ -162,7 +160,6 @@ class StringValidator extends Validator
...
@@ -162,7 +160,6 @@ class StringValidator extends Validator
$options
[
'min'
]
=
$this
->
min
;
$options
[
'min'
]
=
$this
->
min
;
$options
[
'tooShort'
]
=
Html
::
encode
(
strtr
(
$this
->
tooShort
,
array
(
$options
[
'tooShort'
]
=
Html
::
encode
(
strtr
(
$this
->
tooShort
,
array
(
'{attribute}'
=>
$label
,
'{attribute}'
=>
$label
,
'{value}'
=>
$value
,
'{min}'
=>
$this
->
min
,
'{min}'
=>
$this
->
min
,
)));
)));
}
}
...
@@ -170,7 +167,6 @@ class StringValidator extends Validator
...
@@ -170,7 +167,6 @@ class StringValidator extends Validator
$options
[
'max'
]
=
$this
->
max
;
$options
[
'max'
]
=
$this
->
max
;
$options
[
'tooLong'
]
=
Html
::
encode
(
strtr
(
$this
->
tooLong
,
array
(
$options
[
'tooLong'
]
=
Html
::
encode
(
strtr
(
$this
->
tooLong
,
array
(
'{attribute}'
=>
$label
,
'{attribute}'
=>
$label
,
'{value}'
=>
$value
,
'{max}'
=>
$this
->
max
,
'{max}'
=>
$this
->
max
,
)));
)));
}
}
...
@@ -178,7 +174,6 @@ class StringValidator extends Validator
...
@@ -178,7 +174,6 @@ class StringValidator extends Validator
$options
[
'is'
]
=
$this
->
length
;
$options
[
'is'
]
=
$this
->
length
;
$options
[
'notEqual'
]
=
Html
::
encode
(
strtr
(
$this
->
notEqual
,
array
(
$options
[
'notEqual'
]
=
Html
::
encode
(
strtr
(
$this
->
notEqual
,
array
(
'{attribute}'
=>
$label
,
'{attribute}'
=>
$label
,
'{value}'
=>
$value
,
'{length}'
=>
$this
->
is
,
'{length}'
=>
$this
->
is
,
)));
)));
}
}
...
...
framework/yii/validators/UrlValidator.php
View file @
266f4f98
...
@@ -132,7 +132,6 @@ class UrlValidator extends Validator
...
@@ -132,7 +132,6 @@ class UrlValidator extends Validator
'pattern'
=>
new
JsExpression
(
$pattern
),
'pattern'
=>
new
JsExpression
(
$pattern
),
'message'
=>
Html
::
encode
(
strtr
(
$this
->
message
,
array
(
'message'
=>
Html
::
encode
(
strtr
(
$this
->
message
,
array
(
'{attribute}'
=>
$object
->
getAttributeLabel
(
$attribute
),
'{attribute}'
=>
$object
->
getAttributeLabel
(
$attribute
),
'{value}'
=>
$object
->
$attribute
,
))),
))),
'enableIDN'
=>
(
boolean
)
$this
->
enableIDN
,
'enableIDN'
=>
(
boolean
)
$this
->
enableIDN
,
);
);
...
...
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