88
99namespace phpviet \yii \validation \validators ;
1010
11+ use PHPViet \Validation \Rules \IpVN as ConcreteIpVN ;
12+ use PHPViet \Validation \Validator as ConcreteValidator ;
1113use Yii ;
12-
13- use yii \validators \Validator ;
1414use yii \validators \IpValidator ;
15-
16- use PHPViet \Validation \Validator as ConcreteValidator ;
17- use PHPViet \Validation \Rules \IpVN as ConcreteIpVN ;
15+ use yii \validators \Validator ;
1816
1917/**
2018 * @author Vuong Minh <vuongxuongminh@gmail.com>
19+ *
2120 * @since 1.0.0
2221 */
2322class IpVNValidator extends Validator
2423{
25-
2624 const IPV4 = ConcreteIpVN::IPV4 ;
2725
2826 const IPV6 = ConcreteIpVN::IPV6 ;
@@ -33,7 +31,7 @@ class IpVNValidator extends Validator
3331 public $ version ;
3432
3533 /**
36- * @inheritDoc
34+ * {@inheritdoc}
3735 */
3836 public function init ()
3937 {
@@ -43,20 +41,20 @@ public function init()
4341 }
4442
4543 /**
46- * @inheritDoc
44+ * {@inheritdoc}
4745 */
4846 public function validateValue ($ value )
4947 {
5048 if (ConcreteValidator::ipVN ($ this ->version )->validate ($ value )) {
51-
52- return null ;
49+ return ;
5350 }
5451
5552 return [$ this ->message , []];
5653 }
5754
5855 /**
59- * @inheritDoc
56+ * {@inheritdoc}
57+ *
6058 * @throws \yii\base\InvalidConfigException
6159 */
6260 public function clientValidateAttribute ($ model , $ attribute , $ view )
@@ -65,7 +63,8 @@ public function clientValidateAttribute($model, $attribute, $view)
6563 }
6664
6765 /**
68- * @inheritDoc
66+ * {@inheritdoc}
67+ *
6968 * @throws \yii\base\InvalidConfigException
7069 */
7170 public function getClientOptions ($ model , $ attribute )
@@ -74,7 +73,7 @@ public function getClientOptions($model, $attribute)
7473 }
7574
7675 /**
77- * @inheritDoc
76+ * {@inheritdoc}
7877 */
7978 protected function getDefaultMessage (): string
8079 {
@@ -90,30 +89,31 @@ protected function getDefaultMessage(): string
9089
9190 /**
9291 * @var IpValidator
92+ *
9393 * @see getClientIpValidator()
9494 */
9595 private $ _clientIpValidator ;
9696
9797 /**
9898 * Trả về [[IpValidator]] hổ trợ cho việc tạo js validator tại client.
9999 *
100- * @return IpValidator
101100 * @throws \yii\base\InvalidConfigException
101+ *
102+ * @return IpValidator
102103 */
103104 protected function getClientIpValidator (): IpValidator
104105 {
105106 if (null === $ this ->_clientIpValidator ) {
106107 return $ this ->_clientIpValidator = Yii::createObject ([
107- 'class ' => IpValidator::class,
108- 'message ' => $ this ->message ,
108+ 'class ' => IpValidator::class,
109+ 'message ' => $ this ->message ,
109110 'ipv4NotAllowed ' => $ this ->message ,
110111 'ipv6NotAllowed ' => $ this ->message ,
111- 'ipv4 ' => null === $ this ->version || self ::IPV4 === $ this ->version ,
112- 'ipv6 ' => null === $ this ->version || self ::IPV6 === $ this ->version
112+ 'ipv4 ' => null === $ this ->version || self ::IPV4 === $ this ->version ,
113+ 'ipv6 ' => null === $ this ->version || self ::IPV6 === $ this ->version ,
113114 ]);
114115 }
115116
116117 return $ this ->_clientIpValidator ;
117118 }
118-
119119}
0 commit comments