ServiceStack验证程序可以在camel情况下发出字段名称吗?

时间:2017-02-17 22:24:16

标签: servicestack fluentvalidation

有没有办法使用流畅的验证插件强制服务堆栈验证器在camel情况下发出字段名称属性?我已经配置了

private float cornerRadius;
private Path cornersMask;
private static PorterDuffXfermode pdMode = new PorterDuffXfermode(PorterDuff.Mode.CLEAR);

private void initCorners() {
        cornersMask = new Path();
        cornersMask.addRoundRect(new RectF(0, 0, getWidth(), getHeight()), cornerRadius, cornerRadius, Path.Direction.CW);
        cornersMask.setFillType(Path.FillType.INVERSE_WINDING);
}

@Override
public void draw(@NonNull Canvas canvas) {
        int saveCount = canvas.saveLayer(0, 0, getWidth(), getHeight(), null, Canvas.ALL_SAVE_FLAG);

        super.draw(canvas);

        paint.setXfermode(pdMode);
        canvas.drawPath(cornersMask, paint);

        canvas.restoreToCount(saveCount);
        paint.setXfermode(null);
}

因此我的打字稿类型是驼峰式的,但所有验证消息/错误都来自PascalCase。我真的想在我的json响应中保留camelCase,但我确信让字段名称与错误消息字段名称匹配的便利性。这可能吗?

1 个答案:

答案 0 :(得分:0)

EmitCamelCaseNames = true返回的JSON使用camelCase属性名称但数据保留在PacalCase中以匹配Request DTO属性名称时,

不真正关注,例如:

{
  "responseStatus": {
    "errorCode": "InclusiveBetween",
    "message": "'Age' must be between 1 and 120. You entered 0.",
    "errors": [
      {
        "errorCode": "InclusiveBetween",
        "fieldName": "Age",
        "message": "'Age' must be between 1 and 120. You entered 0.",
        "meta": {
          "PropertyName": "Age",
          "From": "1",
          "To": "120",
          "Value": "0"
        }
      }
    ]
  }
}

JSON响应有什么问题?