---
schema_version: "1"
id: 189fac43c1939840e0e561b7fac705a60282a2c81102132eede5f0e80ad837f5
title: Validate the Component (Managed Package)
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/xcloud/264-0-0/os_validate_omniscriptbasemixin_component_vlocity.md
canonical_url: https://help.salesforce.com/s/articleView?id=xcloud.os_validate_omniscriptbasemixin_component_vlocity.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: ca20eacf4ecb63b1142b4dfb6a7dbad7af8a9132de6aa1c5b5898980b2221d45
description: For the managed package runtime, learn how to add validation to the OmniScriptBaseMixin component by redefining the checkValidity() function.
products:
  - Omnistudio
release: "264"
---
# Validate the Component (Managed Package)

For the managed package runtime, learn how to add validation to the OmniScriptBaseMixin component by redefining the `checkValidity()` function.

![Managed Package app icon](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio_for_managed_packages-264-0-0-production-enus/aa2554ec-624a-4ee6-8da4-6435670e6e62/resources-global/_corporate/images/managedpackageicon.png) This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see [Omnistudio Help](https://help.salesforce.com/s/articleView?id=xcloud.os_omnistudio_standard.htm&language=en_US).

1. This code example contains a `checkValidity()` function that returns false when the sum is less than zero. Replace the `NS` variable in the code example with the namespace of the managed package you’re using.
    
    ```
    import { api } from 'lwc';
    import { OmniscriptBaseMixin } from 'NS/omniscriptBaseMixin';
    export default class MyCustomLwc extends OmniscriptBaseMixin(LightningElement) {
       sum = 0;
    
           // defining custom validation conditions   
       @api checkValidity() { 
          return this.sum < 100;
       }
    }
    ```
2. Define a trigger for the custom validation so that the Omniscript can check the custom Lightning web component's validity.
    
    The HTML and JavaScript examples show how the custom validation is called with `omniValidate()` after a user enters their input.
    
    HTML example:
    
    ```
    <template>
        <lightning-input type="number"
                         label="Enter a number between 1 and 5" 
                         onblur={validateOnBlur}
                         onchange={handleChange}
                         required>
        </lightning-input>
    
        <div if:true={showValidation} class="slds-notify slds-notify_alert slds-alert_error" role="alert">
            <h2> Please enter a number between 1 and 5 </h2>
          </div>
    </template>
    ```
    
    JavaScript example:
    
    ```
    import { LightningElement, api } from 'lwc';
    import { OmniscriptBaseMixin } from 'omnistudio/omniscriptBaseMixin';
    export default class MyCustomLwc extends OmniscriptBaseMixin(LightningElement) {
       value = 3;
    
       // defining custom validation conditions 
       // 2,3 or 4 will return true
       // all other numbers will return false
       checkValidity() { 
          return 1 < this.value && this.value < 5;
       }
       
       validateOnBlur() {
          // when parameter is true, sets the variable : showValidation to true
          this.omniValidate(true);
       }
    
       handleChange(event) {
          this.value = event.detail.value;
      }
    }
    ```