syntax = "proto3";

package com.wixpress.appservice.api.upstream.wix.forms.templates.v2.validation;
option java_package = "com.wixpress.appservice.api.upstream.wix.forms.templates.v2.validation";

import "wix/api/validations.proto";
import "google/protobuf/wrappers.proto";
import "wix/api/annotations.proto";
import "components_catalog_data/form_template/com/wixpress/appservice/api/upstream/wix/forms/templates/v2/validation/string_type.proto";
import "components_catalog_data/form_template/com/wixpress/appservice/api/upstream/wix/forms/templates/v2/validation/number_type.proto";
import "components_catalog_data/form_template/com/wixpress/appservice/api/upstream/wix/forms/templates/v2/validation/boolean_type.proto";
import "components_catalog_data/form_template/com/wixpress/appservice/api/upstream/wix/forms/templates/v2/validation/integer_type.proto";

message ArrayType {
  option (.wix.api.decomposite_of) = "wix.forms.templates.v2.validation.ArrayType";
  reserved 4;
  // Maximum amount of array elements.
  google.protobuf.Int32Value max_items = 1 [(.wix.api.min) = 0, (.wix.api.max) = 1000];

  // Minimum amount of array elements.
  google.protobuf.Int32Value min_items = 2 [(.wix.api.min) = 0, (.wix.api.max) = 1000];

  // Type of items allowed in array.
  ArrayItems items = 3;

  message ArrayItems{
    option (.wix.api.decomposite_of) = "wix.forms.templates.v2.validation.ArrayType.ArrayItems";
    enum ItemType {
      UNKNOWN_ITEM_TYPE = 0;
      STRING = 1;
      NUMBER = 2;
      BOOLEAN = 3;
      INTEGER = 4;
      OBJECT = 5;
    }

    // Type of array items
    ItemType item_type = 1 [(.wix.api.readOnly) = true];

    oneof item_type_options {
      option (.wix.api.aligned_with_enum).field = "item_type";
      // String type validation for items.
      wix.forms.templates.v2.validation.StringType string_options = 3;
      // Number type validation for items.
      wix.forms.templates.v2.validation.NumberType number_options = 4;
      // Boolean type validation for items.
      wix.forms.templates.v2.validation.BooleanType boolean_options = 5;
      // Integer type validation for items.
      wix.forms.templates.v2.validation.IntegerType integer_options = 6;
      // Object type validation for items
      wix.forms.templates.v2.validation.ObjectType object_options = 7;
    };
  }
}

message ObjectType {
  option (.wix.api.decomposite_of) = "wix.forms.templates.v2.validation.ArrayType.ObjectType";
  reserved 2;

  // Description of object properties.
  map<string, PropertiesType> properties = 1;

  message PropertiesType{
    option (.wix.api.decomposite_of) = "wix.forms.templates.v2.validation.ArrayType.ObjectType.PropertiesType";
    enum PropertiesTypeEnum {
      UNKNOWN_PROPERTY_TYPE = 0;
      STRING = 1;
      NUMBER = 2;
      BOOLEAN = 3;
      INTEGER = 4;
      ARRAY = 5;
    }

    // Type of object properties
    PropertiesTypeEnum properties_type = 1 [(.wix.api.readOnly) = true];

    oneof properties_type_options {
      option (.wix.api.aligned_with_enum).field = "properties_type";
      // String type validation for property.
      wix.forms.templates.v2.validation.StringType string_options = 2;
      // Number type validation for property.
      wix.forms.templates.v2.validation.NumberType number_options = 3;
      // Boolean type validation for property.
      wix.forms.templates.v2.validation.BooleanType boolean_options = 4;
      // Integer type validation for property.
      wix.forms.templates.v2.validation.IntegerType integer_options = 5;
      // Array type validation for property.
      wix.forms.templates.v2.validation.ArrayType array_options = 6;
    };
    // Whether the property is required.
    bool required = 7;
  }
}
