# BindingEngine in a nodejs application

**URL:** <https://discourse.aurelia.io/t/bindingengine-in-a-nodejs-application/3215>\
**Category:** Help Requests\
**Created:** [February 5, 2020, 11:58am UTC](https://discourse.aurelia.io/t/bindingengine-in-a-nodejs-application/3215 "2020-02-05T11:58:25Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![elitemike](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/elitemike/32/690_2.png) [@elitemike](https://discourse.aurelia.io/u/elitemike)\
**Post date:** [February 18, 2021, 5:10pm UTC](https://discourse.aurelia.io/t/bindingengine-in-a-nodejs-application/3215/15 "2021-02-18T17:10:17Z")

</div>

Update: Created new topic at [Aurelia-validation plugin in NodeJs](https://discourse.aurelia.io/t/aurelia-validation-plugin-in-nodejs/4051)

It’s been a little while since I worked on this. Practically a year ago. I’m finally revisiting this and I made progress but I’m now getting an error due to the way I’m trying to share code between the web and the server. I’m getting the friendly message ’ Did you forget to add “.plugin(‘aurelia-validation’)” to your main.js?’ How can I make that work in a node project? My code is actually running correctly up to this point if I pass in something that does not require validation.

```auto
(node:18088) UnhandledPromiseRejectionWarning: Error: Did you forget to add ".plugin('aurelia-validation')" to your main.js?
    at FluentEnsure.assertInitialized (C:\source\control_set\node_modules\aurelia-validation\dist\commonjs\aurelia-validation.js:1779:15)
    at FluentEnsure.ensure (C:\source\control_set\node_modules\aurelia-validation\dist\commonjs\aurelia-validation.js:1744:14)
    at Function.ValidationRules.ensure (C:\source\control_set\node_modules\aurelia-validation\dist\commonjs\aurelia-validation.js:1812:58)

```

My rules are defined as such

```auto
            ValidationRules.ensure((c: StringControlConfiguration) => c.value)
                .required()
                .when(() => control.validation.required && control.canValidate)
                .withMessage(`${control.label || control.placeholder} is required`)
                .satisfies((value: string) => {
                    return value !== null ? value.indexOf(control.promptChar) === -1 : true;
                })
                .when(() => control.mask !== null && control.promptChar !== null && control.canValidate)
                .withMessage(`${control.label || control.placeholder} does not meet the format: ${control.mask}`)
                .matches(control.validation.regEx)
                .when(() => control.validation.regEx !== null && control.canValidate)
                .withMessage(`${control.label || control.placeholder} is invalid (${control.validation.regEx})`)
                .satisfies(control.isValidRegEx)
                .when(() => control.inputType === 'regularExpression' && control.canValidate)
                .withMessage(`${control.label || control.placeholder} is not a valid regular expression`)
                .maxLength(control.validation.maxLength)
                .when(() => control.validation.maxLength !== null && control.canValidate)
                .withMessage(
                    `${control.label || control.placeholder} must be less than ${
                        control.validation.maxLength
                    } characters`
                )
                .minLength(control.validation.minLength)
                .when(() => control.validation.minLength !== null && control.canValidate)
                .withMessage(
                    `${control.label || control.placeholder} must be greater than ${
                        control.validation.minLength
                    } characters`
                ).satisfies((value: string) => {
                    return value !==null ? !control.validation.restrictedValues.some((x) => x.toLowerCase() === value.toLowerCase()): true
                })
                .when(() => control.validation.restrictedValues !== null)
                .withMessage(`${control.label || control.placeholder || "Input"} cannot contain the current value`)
                .on(control);

```

---

_[View the full topic](https://discourse.aurelia.io/t/bindingengine-in-a-nodejs-application/3215)._
