Custom validation class not working

I was trying to write a validation class for validating postal

I place the file in app\components\PostalcodeValidation

<?php

namespace app\components;

use yii\validators\Validator;

use app\models\Status;

class PostCodeValidator extends Validator

{

public function init()


{


    parent::init();


    &#036;this-&gt;message = 'Invalid status input.';


}





public function validateAttribute(&#036;model, &#036;attribute) {


     &#036;value = &#036;model-&gt;&#036;attribute;


     return true;


     


}








 public function clientValidateAttribute(&#036;model, &#036;attribute, &#036;view) {


    &#036;message = json_encode('Invalid pincode', JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);


    return &lt;&lt;&lt;JS


    var regexObj = {


    canada: /^[ABCEGHJKLMNPRSTVXY]&#092;d[ABCEGHJKLMNPRSTVWXYZ]( )?&#092;d[ABCEGHJKLMNPRSTVWXYZ]&#092;d&#036;/i, //i for case-insensitive


    usa: /^&#092;d{5}(-&#092;d{4})?&#036;/,


        }


  


var regexp = new RegExp(regexObj.canada);


if (regexp.test(value)) {


    return true;


}


regexp = null;


regexp = new RegExp(regexObj.usa);


if (regexp.test(value)) {


    return true;


}





messages.push(&quot;Not a valid Postal Code or Zip Code&quot;);

JS;

}

}

I want to use this class to validation in model

public function rules() {

    return [


           [['postal_code'], 'app&#092;components&#092;PostCodeValidator', ],


           ];


            }

It works fine when I follow basic template file structure .

when I change move web folder to sub directory yii generate error app\components\PostCodeValidator

What I think is that component folder is not registered in yii2 so I am getting error

Can any one help how to resolve this problem

how to register a new folder to yii 2

I used this reference to create this class but there also it is not mentioned how to use it

http://www.yiiframework.com/doc-2.0/guide-input-validation.html#implementing-client-side-validation

Thanks