TIOModelBundleValidator

@interface TIOModelBundleValidator : NSObject

TIOModelBundleValidator is responsible for ensuring that the contents of a TensorIO bundle are valid.

The bundle validator will commonly be used to validate bundles that are deployed after release of an app rather than those that are packaged with it. It validates each part of the TensorIO model spec, and also allows the client to provide a custom validation block.

  • Instantiates a bundle validator with a model bundle.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithModelBundleAtPath:(nonnull NSString *)path;

    Swift

    init(modelBundleAtPath path: String)

    Parameters

    path

    A path to a .tfbundle folder that will be validated.

    Return Value

    instancetype A validator instance.

  • Unavailable

    Use the designated initializer.

    Declaration

    Objective-C

    - (nonnull instancetype)init;
  • The path to the bundle which is being evaluated.

    Declaration

    Objective-C

    @property (readonly, atomic) NSString *_Nonnull path;

    Swift

    var path: String { get }
  • The JSON in the model.json file for which the bundle is being evaluated

    Declaration

    Objective-C

    @property (readonly, atomic) NSDictionary *_Nonnull JSON;

    Swift

    var json: [AnyHashable : Any] { get }
  • Validates the bundle which was provided at initialization. Use this method to validate models.

    Declaration

    Objective-C

    - (BOOL)validate:(TIOModelBundleValidationBlock _Nullable)customValidator
               error:(NSError *_Nullable *_Nullable)error;

    Swift

    func validate(_ customValidator: TIOModelBundleValidationBlock? = nil, error: ()) throws

    Parameters

    customValidator

    A custom validation block for application specific validation

    error

    Pointer to an NSError that will be set if the bundle could not be validated.

    Return Value

    BOOL YES if the bundle was successfully validated, NO otherwise.

  • A convenience method for validating the bundle when no custom validation is needed.

    Declaration

    Objective-C

    - (BOOL)validate:(NSError *_Nullable *_Nullable)error;

    Swift

    func validate() throws

    Parameters

    error

    Pointer to an NSError that will be set if the bundle could not be validated.

    Return Value

    BOOL YES if the bundle was successfully validated, NO otherwise.

  • Validates basic bundle properties from a JSON dictionary. Called by validate:error:

    Declaration

    Objective-C

    - (BOOL)validateBundleProperties:(nonnull NSDictionary *)JSON
                               error:(NSError *_Nullable *_Nullable)error;

    Swift

    func validateBundleProperties(_ JSON: [AnyHashable : Any]) throws

    Parameters

    JSON

    The bundle properties loaded from a model.json file.

    error

    Pointer to an NSError that will be set if the bundle properties could not be validated.

    Return Value

    BOOL YES if the bundle was successfully validated, NO otherwise.

  • Validates basic model properties from a JSON dictionary. Called by validate:error:

    The validate:error: function passes the value of the model field to this method.

    Declaration

    Objective-C

    - (BOOL)validateModelProperties:(nonnull NSDictionary *)JSON
                              error:(NSError *_Nullable *_Nullable)error;

    Swift

    func validateModelProperties(_ JSON: [AnyHashable : Any]) throws

    Parameters

    JSON

    The model properties loaded from a model.json file.

    error

    Pointer to an NSError that will be set if the model properties could not be validated.

    Return Value

    BOOL YES if the bundle was successfully validated, NO otherwise.

  • Validates presence of assets identified in JSON dictionary. Called by validate:error:

    Declaration

    Objective-C

    - (BOOL)validateAssets:(nonnull NSDictionary *)JSON
                     error:(NSError *_Nullable *_Nullable)error;

    Swift

    func validateAssets(_ JSON: [AnyHashable : Any]) throws

    Parameters

    JSON

    The bundle properties loaded from a model.json file.

    error

    Pointer to an NSError that will be set if the assets could not be located.

    Return Value

    BOOL YES if the bundle was successfully validated, NO otherwise.

  • Validates input properties from a JSON array. Called by validate:error:

    The validate:error: function passes the value of the inputs field to this method.

    Declaration

    Objective-C

    - (BOOL)validateInputs:(nonnull NSArray *)JSON
                     error:(NSError *_Nullable *_Nullable)error;

    Swift

    func validateInputs(_ JSON: [Any]) throws

    Parameters

    JSON

    The bundle properties loaded from a model.json file.

    error

    Pointer to an NSError that will be set if the input properties could not be validated.

    Return Value

    BOOL YES if the bundle was successfully validated, NO otherwise.

  • Validates input properties from a JSON array. Called by validate:error:

    The validate:error: function passes the value of the outputs field to this method.

    Declaration

    Objective-C

    - (BOOL)validateOutputs:(nonnull NSArray *)JSON
                      error:(NSError *_Nullable *_Nullable)error;

    Swift

    func validateOutputs(_ JSON: [Any]) throws

    Parameters

    JSON

    The bundle properties loaded from a model.json file.

    error

    Pointer to an NSError that will be set if the output properties could not be validated.

    Return Value

    BOOL YES if the bundle was successfully validated, NO otherwise.

  • Executes a custom validator. Called by validate:error:

    The validate:error: function passes the custom validator provided there to this function.

    Declaration

    Objective-C

    - (BOOL)validateCustomValidator:(nonnull NSDictionary *)JSON
                          validator:
                              (nonnull TIOModelBundleValidationBlock)customValidator
                              error:(NSError *_Nullable *_Nullable)error;

    Swift

    func validateCustomValidator(_ JSON: [AnyHashable : Any], validator customValidator: @escaping TIOModelBundleValidationBlock) throws

    Parameters

    JSON

    The bundle properties loaded from a model.json file.

    customValidator

    The custom validator provided to the validate:error: function.

    error

    Pointer to an NSError that will be set if the output properties could not be validated.

    Return Value

    BOOL YES if the bundle was successfully validated, NO otherwise.