Skip to content

Conversation

ryodocx
Copy link
Owner

@ryodocx ryodocx commented Jun 17, 2022

Summary

  • In this PullRequest, add validator in order to count string length correctly.
  • Current, StringLenBetween() count byte length.
  • For example Japanese, 1 character mean 2 bytes.
    • Sometimes, improper validation implements in terraform-provider via this behavior

What's changes?

  • add StringRuneCountBetween() for count string length
  • add StringBytesBetween() for count byte length (it's just copy of StringLenBetween())
  • add validation for parameters(min, max)
  • add test

Related issues


test viewpoint

テスト観点メモ

    • string型: OK
    • string以外の型: NG
  • 閾値の数値
    • 負数: NG
    • 0: OK
    • 正数: OK
  • 閾値の関係
    • Min = Max: OK
    • Min < Max: OK
    • Min > Max: NG
  • 閾値(Min)
    • 文字数(Byte数)より小さい: OK
    • 文字数(Byte数)と同じ: OK
    • 文字数(Byte数)より大きい: NG
  • 閾値(Max)
    • 文字数(Byte数)より小さい: NG
    • 文字数(Byte数)と同じ: OK
    • 文字数(Byte数)より大きい: OK
  • 文字種
    • シングルバイト文字(ASCII)
      • 空白
      • 制御文字
      • 図形文字(通常文字)
    • 2バイト文字
    • 3バイト文字
    • 4バイト文字

@ryodocx ryodocx changed the title add validator: StringRuneCountBetween and StringBytesBetween add validator: StringRuneCountBetween() and StringBytesBetween() instead StringLenBetween() Jun 19, 2022
@ryodocx
Copy link
Owner Author

ryodocx commented Jun 19, 2022

move to: hashicorp#985

@ryodocx ryodocx closed this Jun 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant