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
5069c29b
Commit
5069c29b
authored
May 02, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished js validation for URL validator.
parent
4b30fe8b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
29 deletions
+32
-29
yii.validation.js
framework/assets/yii.validation.js
+17
-3
FileValidator.php
framework/validators/FileValidator.php
+0
-1
UrlValidator.php
framework/validators/UrlValidator.php
+15
-25
No files found.
framework/assets/yii.validation.js
View file @
5069c29b
...
@@ -81,6 +81,16 @@ yii.validation = (function ($) {
...
@@ -81,6 +81,16 @@ yii.validation = (function ($) {
valid
||
messages
.
push
(
options
.
message
);
valid
||
messages
.
push
(
options
.
message
);
},
},
regularExpression
:
function
(
value
,
messages
,
options
)
{
if
(
options
.
skipOnEmpty
&&
isEmpty
(
value
))
{
return
;
}
if
(
!
value
.
match
(
options
.
pattern
))
{
messages
.
push
(
options
.
message
)
}
},
email
:
function
(
value
,
messages
,
options
)
{
email
:
function
(
value
,
messages
,
options
)
{
if
(
options
.
skipOnEmpty
&&
isEmpty
(
value
))
{
if
(
options
.
skipOnEmpty
&&
isEmpty
(
value
))
{
return
;
return
;
...
@@ -91,14 +101,18 @@ yii.validation = (function ($) {
...
@@ -91,14 +101,18 @@ yii.validation = (function ($) {
valid
||
messages
.
push
(
options
.
message
);
valid
||
messages
.
push
(
options
.
message
);
},
},
regularExpression
:
function
(
value
,
messages
,
options
)
{
url
:
function
(
value
,
messages
,
options
)
{
if
(
options
.
skipOnEmpty
&&
isEmpty
(
value
))
{
if
(
options
.
skipOnEmpty
&&
isEmpty
(
value
))
{
return
;
return
;
}
}
if
(
!
value
.
match
(
options
.
pattern
))
{
if
(
options
.
defaultScheme
&&
!
value
.
match
(
/:
\/\/
/
))
{
messages
.
push
(
options
.
message
)
value
=
options
.
defaultScheme
+
'://'
+
value
;
}
}
if
(
!
value
.
match
(
options
.
pattern
))
{
messages
.
push
(
options
.
message
);
}
}
},
};
};
})(
jQuery
);
})(
jQuery
);
framework/validators/FileValidator.php
View file @
5069c29b
...
@@ -8,7 +8,6 @@
...
@@ -8,7 +8,6 @@
namespace
yii\validators
;
namespace
yii\validators
;
use
Yii
;
use
Yii
;
use
yii\helpers\FileHelper
;
use
yii\web\UploadedFile
;
use
yii\web\UploadedFile
;
/**
/**
...
...
framework/validators/UrlValidator.php
View file @
5069c29b
...
@@ -8,6 +8,9 @@
...
@@ -8,6 +8,9 @@
namespace
yii\validators
;
namespace
yii\validators
;
use
Yii
;
use
Yii
;
use
yii\helpers\Html
;
use
yii\helpers\JsExpression
;
use
yii\helpers\Json
;
/**
/**
* UrlValidator validates that the attribute value is a valid http or https URL.
* UrlValidator validates that the attribute value is a valid http or https URL.
...
@@ -100,40 +103,27 @@ class UrlValidator extends Validator
...
@@ -100,40 +103,27 @@ class UrlValidator extends Validator
*/
*/
public
function
clientValidateAttribute
(
$object
,
$attribute
)
public
function
clientValidateAttribute
(
$object
,
$attribute
)
{
{
$message
=
strtr
(
$this
->
message
,
array
(
'{attribute}'
=>
$object
->
getAttributeLabel
(
$attribute
),
'{value}'
=>
$object
->
$attribute
,
));
if
(
strpos
(
$this
->
pattern
,
'{schemes}'
)
!==
false
)
{
if
(
strpos
(
$this
->
pattern
,
'{schemes}'
)
!==
false
)
{
$pattern
=
str_replace
(
'{schemes}'
,
'('
.
implode
(
'|'
,
$this
->
validSchemes
)
.
')'
,
$this
->
pattern
);
$pattern
=
str_replace
(
'{schemes}'
,
'('
.
implode
(
'|'
,
$this
->
validSchemes
)
.
')'
,
$this
->
pattern
);
}
else
{
}
else
{
$pattern
=
$this
->
pattern
;
$pattern
=
$this
->
pattern
;
}
}
$js
=
"
$options
=
array
(
if(!value.match(
$pattern
)) {
'pattern'
=>
new
JsExpression
(
$pattern
),
messages.push("
.
json_encode
(
$message
)
.
");
'message'
=>
Html
::
encode
(
strtr
(
$this
->
message
,
array
(
}
'{attribute}'
=>
$object
->
getAttributeLabel
(
$attribute
),
"
;
'{value}'
=>
$object
->
$attribute
,
if
(
$this
->
defaultScheme
!==
null
)
{
))),
$js
=
"
);
if(!value.match(/:
\\
/
\\
//)) {
value="
.
json_encode
(
$this
->
defaultScheme
)
.
"+'://'+value;
}
$js
"
;
}
if
(
$this
->
skipOnEmpty
)
{
if
(
$this
->
skipOnEmpty
)
{
$js
=
"
$options
[
'skipOnEmpty'
]
=
1
;
if($.trim(value)!='') {
}
$js
if
(
$this
->
defaultScheme
!==
null
)
{
}
$options
[
'defaultScheme'
]
=
$this
->
defaultScheme
;
"
;
}
}
return
$js
;
return
'yii.validation.url(value, messages, '
.
Json
::
encode
(
$options
)
.
');'
;
}
}
}
}
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