com.versionone.apiclient

## Class RequiredFieldValidator

- java.lang.Object
- - com.versionone.apiclient.RequiredFieldValidator

-     public class RequiredFieldValidator
      extends Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RequiredFieldValidator(IMetaModel metaModel, IServices services)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `isRequired(IAssetType assetType, String attributeName)` Check whether the attribute corresponding to the attributeName is required in current VersionOne server setup.
    `boolean` | `isRequired(IAttributeDefinition definition)` Check whether the provided attribute is required in current VersionOne server setup.
    `List<IAttributeDefinition>` | `validate(Asset asset)` Validate all available Asset attributes.
    `Map<Asset,List<IAttributeDefinition>>` | `validate(Asset[] assets)` Validate collection of Assets.
    `boolean` | `validate(Asset asset, IAttributeDefinition attributeDefinition)` Validate single Asset attribute.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RequiredFieldValidator

          public RequiredFieldValidator(IMetaModel metaModel,
                                        IServices services)

  - ### Method Detail

    - #### validate

          public boolean validate(Asset asset,
                                  IAttributeDefinition attributeDefinition)
                           throws APIException,
                                  ConnectionException,
                                  OidException

      Validate single Asset attribute. If attribute is not loaded, it is just considered invalid.
      Parameters:
        `asset` - - Asset to validate
        `attributeDefinition` - - Attribute definition of validated attribute
      Returns:
        Validation result
      Throws:
        `APIException` - - APIException
        `OidException` - - OidException
        `ConnectionException` - - ConnectionException

    - #### validate

          public List<IAttributeDefinition> validate(Asset asset)
                                              throws APIException,
                                                     ConnectionException,
                                                     OidException

      Validate all available Asset attributes. If there are required attributes that haven't been loaded, these are considered failures. In some cases, attributes could exist on server and have valid values, but it's up to user to retrieve them or ignore corresponding validation errors.
      Parameters:
        `asset` - - Asset to validate
      Returns:
        Collection of attribute definitions for attributes which values do not pass validation
      Throws:
        `APIException` - - APIException
        `OidException` - - OidException
        `ConnectionException` - - ConnectionException

    - #### validate

          public Map<Asset,List<IAttributeDefinition>> validate(Asset[] assets)
                                                         throws APIException,
                                                                ConnectionException,
                                                                OidException

      Validate collection of Assets.
      Parameters:
        `assets` - - Assets collection to check.
      Returns:
        Validation results dictionary, each entry value key is Asset, and value is output of @seeValidate(Asset)
      Throws:
        `APIException` - - APIException
        `OidException` - - OidException
        `ConnectionException` - - ConnectionException

    - #### isRequired

          public boolean isRequired(IAssetType assetType,
                                    String attributeName)
                             throws ConnectionException,
                                    APIException,
                                    OidException,
                                    MetaException

      Check whether the attribute corresponding to the attributeName is required in current VersionOne server setup.
      Parameters:
        `assetType` - - Asset type.
        `attributeName` - - Attribute name.
      Returns:
        is specified attribute required for specified asset.
      Throws:
        `MetaException` - - MetaException
        `OidException` - - OidException
        `APIException` - - APIException
        `ConnectionException` - - ConnectionException

    - #### isRequired

          public boolean isRequired(IAttributeDefinition definition)
                             throws ConnectionException,
                                    APIException,
                                    OidException,
                                    MetaException

      Check whether the provided attribute is required in current VersionOne server setup.
      Parameters:
        `definition` - - Attribute definition.
      Returns:
        is specified attribute definition required.
      Throws:
        `MetaException` - - MetaException
        `OidException` - - OidException
        `APIException` - - APIException
        `ConnectionException` - - ConnectionException

Copyright © 2022 VersionOne, Inc.. All rights reserved.