私のエンティティ フレームワーク モデル内には、次のものがあります。
<Required(), Range(0, Double.MaxValue, ErrorMessage:="Weight must be numeric and cannot be negative")> _
Public Property Weight() As Double
<Required(), Range(0, Double.MaxValue, ErrorMessage:="Recycled content must be numeric and between 0 and 100")> _
Public Property RecycledContent() As Double
そして、私のビューモデルには次のものがあります:
if (!editComponent().entityAspect.validateProperty("recycledContent")) {
/* do something about errors */
var msg = 'Recycled content is invalid!';
logger.logError(msg, error, system.getModuleId(lt_articleEdit), true);
}
それでも、(リサイクルされたコンテンツ フィールドに) 100 より大きい値を入力すると、何らかの形で検証に合格します! 私はスクリプトデバッガーを使用してステップスルーし、そよ風の検証ルーチンには「必須」と「番号」の2つのバリデーターが登録されていますが、範囲について言及しているものはありません。
そよ風は範囲検証を行うことができますか? 私がやろうとしているのは、モデルのデータ注釈からのメタデータに基づいてデータ検証エラーを取得し、これを使用してエラーのあるフィールドでクライアント側の強調表示をトリガーし、エラー メッセージをログに記録することだけです。