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";

message StringType {
    option (.wix.api.decomposite_of) = "wix.forms.templates.v2.validation.StringType";
  reserved 5;
  // Minimum length.
  google.protobuf.Int32Value min_length = 1 [(.wix.api.min) = 0, (.wix.api.max) = 20000];

  // Maximum length.
  google.protobuf.Int32Value max_length = 2 [(.wix.api.min) = 0, (.wix.api.max) = 20000];

  // Pattern for a regular expression match.
  google.protobuf.StringValue pattern = 3 [(.wix.api.maxLength) = 500];

  // Format of a string.
  FormatEnum.Format format = 4;

  // List of allowed values.
  repeated google.protobuf.StringValue enum = 6 [(.wix.api.maxSize) = 500, (.wix.api.maxLength) = 20000];

  oneof format_options {
    // DATE format options
    DateTimeConstraints date_options = 7;
    // DATE_TIME format options
    DateTimeConstraints date_time_options = 8;
    // TIME format options
    DateTimeConstraints time_options = 9;
    // DATE_OPTIONAL_TIME format options
    DateTimeConstraints date_optional_time_options = 10;
    // PHONE format options
    PhoneConstraints phone_options = 11;
  }

  message DateTimeConstraints {
    option (.wix.api.decomposite_of) = "wix.forms.templates.v2.validation.DateTimeConstraints";
    // Support static constrains defined as ISO date/time format, as well as
    // dynamic calculations can be performed using special keywords such as "$now" to represent the current date and time.
    // The dynamic calculation supports expressions like "$now+2d" (2 days in the future), "$now-1h" (1 hour in the past), etc.
    // The regex pattern for dynamic calculations is: \$now([+-]\d{1,2})([yMdmh])
    google.protobuf.StringValue minimum = 7 [(.wix.api.maxLength) = 50];

    // Support static constrains defined as ISO date/time format, as well as
    // dynamic calculations can be performed using special keywords such as "$now" to represent the current date and time.
    // The dynamic calculation supports expressions like "$now+2d" (2 days in the future), "$now-1h" (1 hour in the past), etc.
    // The regex pattern for dynamic calculations is: \$now([+-]\d{1,2})([yMdmh])
    google.protobuf.StringValue maximum = 8 [(.wix.api.maxLength) = 50];
  }

  message PhoneConstraints {
    option (.wix.api.decomposite_of) = "wix.forms.templates.v2.validation.PhoneConstraints";
    // Country codes for phone number that are allowed
    repeated string allowed_country_codes = 1 [(.wix.api.maxSize) = 250, (.wix.api.maxLength) = 2];
  }

  message FormatEnum {
    option (.wix.api.decomposite_of) = "wix.forms.templates.v2.validation.FormatEnum";
    enum Format {
      UNKNOWN_FORMAT = 0;
      DATE = 1;
      TIME = 2;
      DATE_TIME = 3;
      EMAIL = 4;
      URL = 5;
      UUID = 6;
      PHONE = 7;
      URI = 8;
      HOSTNAME = 9;
      COLOR_HEX = 10;
      CURRENCY = 11;
      LANGUAGE = 12;
      DATE_OPTIONAL_TIME = 13;
    }
  }
}
