LoginSignup
0
0

More than 5 years have passed since last update.

Hyperledger ComposerのModel File作成時のTips #変数の初期値と入力制限

Last updated at Posted at 2018-01-30

Hyperledger Composerとは

オープンソースのブロックチェーンであるHyperledger Fabricの開発フレームワークです。開発者は、ブロックチェーンの基盤技術をあまり意識する必要がなく、ブロックチェーン上の参加者定義やトランザクションなどのサービス開発に集中することができます。

Model Fileとは

Hyperleger Composerのネットワーク上の参加者participantや、参加者が取引や作用する資産assetを定義するファイルです。Modeling Languageという書き方で記述します。

本Tips

participantや、assetにはString型やDouble型などのプロパティを設定できます。

String型を使う場合には、participantassetが不適切なデータを保有して、ブロックチェーン上に追加されないように、デフォルト値の設定や入力制限をかけたい場合があります。

それらは、以下の記述で実現できます(assetを例にしています)。

asset SmapleAsset identified by assetId {

  o String assetId

  //デフォルト値なし、入力制限なし
  o String assetName

  //デフォルト値の設定
  o String ownerName default = "test-user" 

  //正規表現による入力制限の設定 ex)"2018/01/01-2018/12/31" 
  o String validityPeriod regex=/((20|[2-9][0-9])[0-9]{2}\/(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01]))-(20|[2-9][0-9])[0-9]{2}\/(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])/  

}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0