public void validateForCreateSettlementSequenceData(String json) {

    if (StringUtils.isBlank(json)) {
      throw new InvalidJsonException();
    }

    final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
    final DataValidatorBuilder baseDataValidator =
        new DataValidatorBuilder(dataValidationErrors).resource("media.settlement");

    final JsonElement element = fromApiJsonHelper.parse(json);

    final Long partnerType1 = fromApiJsonHelper.extractLongNamed("partnerType1", element);
    baseDataValidator.reset().parameter("partnerType1").value(partnerType1).notNull();

    final Long partnerType2 = fromApiJsonHelper.extractLongNamed("partnerType2", element);
    baseDataValidator.reset().parameter("partnerType2").value(partnerType2).notNull();

    final Long partnerType3 = fromApiJsonHelper.extractLongNamed("partnerType3", element);
    baseDataValidator.reset().parameter("partnerType3").value(partnerType3).notNull();

    if (fromApiJsonHelper.parameterExists("settlementSequenceData", element)) {

      final JsonArray ssDataArray =
          fromApiJsonHelper.extractJsonArrayNamed("settlementSequenceData", element);

      if (ssDataArray == null) {
        /*throw new PlatformDataIntegrityException("Please select channel partners", "Please select channel partners", "");*/
      }
      String[] ssStringArray = new String[ssDataArray.size()];

      for (int i = 0; i < ssDataArray.size(); i++) {
        ssStringArray[i] = ssDataArray.get(i).toString();
      }

      for (String s : ssStringArray) {

        final JsonElement el = fromApiJsonHelper.parse(s);
        final Long partnerType4 = fromApiJsonHelper.extractLongNamed("partnerType4", el);
        baseDataValidator.reset().parameter("partnerType4").value(partnerType4).notNull();

        final Long partnerType5 = fromApiJsonHelper.extractLongNamed("partnerType5", el);
        baseDataValidator.reset().parameter("partnerType5").value(partnerType5).notNull();

        final Long partnerType6 = fromApiJsonHelper.extractLongNamed("partnerType6", el);
        baseDataValidator.reset().parameter("partnerType6").value(partnerType6).notNull();

        /*final String channelPartnerAddress = fromApiJsonHelper.extractStringNamed("channelPartnerAddress", el);
        baseDataValidator.reset().parameter("channelPartnerAddress").value(channelPartnerAddress).notBlank();
        throwExceptionIfValidationWarningsExist(dataValidationErrors);*/
      }
    }
    throwExceptionIfValidationWarningsExist(dataValidationErrors);
  }
  /** Validation for Close Ticket */
  public void validateForClose(final String json) {
    if (StringUtils.isBlank(json)) {
      throw new InvalidJsonException();
    }

    final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
    fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParameters);

    final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
    final DataValidatorBuilder baseDataValidator =
        new DataValidatorBuilder(dataValidationErrors).resource("ticketmaster");

    final JsonElement element = fromApiJsonHelper.parse(json);

    Integer status = null;
    String resolutionDescription = null;

    if (fromApiJsonHelper.parameterExists("status", element)) {
      status = Integer.parseInt(fromApiJsonHelper.extractStringNamed("status", element));
    }
    if (fromApiJsonHelper.parameterExists("resolutionDescription", element)) {
      resolutionDescription =
          fromApiJsonHelper.extractStringNamed("resolutionDescription", element);
    }

    baseDataValidator
        .reset()
        .parameter("status")
        .value(status)
        .notBlank()
        .notExceedingLengthOf(100);
    baseDataValidator
        .reset()
        .parameter("resolutionDescription")
        .value(resolutionDescription)
        .notBlank()
        .notExceedingLengthOf(100);

    throwExceptionIfValidationWarningsExist(dataValidationErrors);
  }
  public void validateForUpdate(final String json) {
    if (StringUtils.isBlank(json)) {
      throw new InvalidJsonException();
    }

    final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
    fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParameters);

    final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
    final DataValidatorBuilder baseDataValidator =
        new DataValidatorBuilder(dataValidationErrors).resource("role");

    final JsonElement element = fromApiJsonHelper.parse(json);

    if (fromApiJsonHelper.parameterExists("name", element)) {
      final String username = fromApiJsonHelper.extractStringNamed("name", element);
      baseDataValidator
          .reset()
          .parameter("name")
          .value(username)
          .notBlank()
          .notExceedingLengthOf(100);
    }

    if (fromApiJsonHelper.parameterExists("description", element)) {
      final String description = fromApiJsonHelper.extractStringNamed("description", element);
      baseDataValidator
          .reset()
          .parameter("description")
          .value(description)
          .notBlank()
          .notExceedingLengthOf(500);
    }

    throwExceptionIfValidationWarningsExist(dataValidationErrors);
  }
 /** Validation for advanced accounting options */
 private void validatePaymentChannelFundSourceMappings(
     final DataValidatorBuilder baseDataValidator, final JsonElement element) {
   if (fromApiJsonHelper.parameterExists(
       SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(),
       element)) {
     JsonArray paymentChannelMappingArray =
         fromApiJsonHelper.extractJsonArrayNamed(
             SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(),
             element);
     if (paymentChannelMappingArray != null && paymentChannelMappingArray.size() > 0) {
       int i = 0;
       do {
         final JsonObject jsonObject = paymentChannelMappingArray.get(i).getAsJsonObject();
         final Long paymentTypeId =
             jsonObject.get(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_TYPE.getValue()).getAsLong();
         final Long paymentSpecificFundAccountId =
             jsonObject.get(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue()).getAsLong();
         baseDataValidator
             .reset()
             .parameter(
                 SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue()
                     + "["
                     + i
                     + "]."
                     + SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_TYPE.toString())
             .value(paymentTypeId)
             .notNull()
             .integerGreaterThanZero();
         baseDataValidator
             .reset()
             .parameter(
                 SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue()
                     + "["
                     + i
                     + "]."
                     + SAVINGS_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue())
             .value(paymentSpecificFundAccountId)
             .notNull()
             .integerGreaterThanZero();
         i++;
       } while (i < paymentChannelMappingArray.size());
     }
   }
 }
  public void validateForCreate(String json) {

    if (StringUtils.isBlank(json)) {
      throw new InvalidJsonException();
    }

    final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
    fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParameters);

    final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
    final DataValidatorBuilder baseDataValidator =
        new DataValidatorBuilder(dataValidationErrors).resource("payment");

    final JsonElement element = fromApiJsonHelper.parse(json);

    // final LocalDate paymentDate = fromApiJsonHelper.extractLocalDateNamed("paymentDate",
    // element);
    final String paymentCode = fromApiJsonHelper.extractStringNamed("paymentCode", element);
    final BigDecimal amountPaid =
        fromApiJsonHelper.extractBigDecimalWithLocaleNamed("amountPaid", element);
    // final String remarks = fromApiJsonHelper.extractStringNamed("remarks", element);

    /*String receiptNo = fromApiJsonHelper.extractStringNamed("receiptNo", element);
    baseDataValidator.reset().parameter("receiptNo").value(receiptNo).notBlank().notExceedingLengthOf(20);*/
    //	baseDataValidator.reset().parameter("paymentDate").value(paymentDate)
    // .notBlank().notExceedingLengthOf(100);
    baseDataValidator
        .reset()
        .parameter("paymentCode")
        .value(paymentCode)
        .notBlank()
        .notExceedingLengthOf(100);
    baseDataValidator
        .reset()
        .parameter("amountPaid")
        .value(amountPaid)
        .notBlank()
        .notExceedingLengthOf(100);
    // baseDataValidator.reset().parameter("remarks").value(remarks)
    // .notBlank().notExceedingLengthOf(100);
    if (fromApiJsonHelper.parameterExists("isChequeSelected", element)) {
      String isChequeSelected = fromApiJsonHelper.extractStringNamed("isChequeSelected", element);
      if (isChequeSelected.equalsIgnoreCase("yes")) {
        if (fromApiJsonHelper.parameterExists("chequeNo", element)) {
          String chequeNo = fromApiJsonHelper.extractStringNamed("chequeNo", element);
          baseDataValidator
              .reset()
              .parameter("chequeNo")
              .value(chequeNo)
              .notBlank()
              .notExceedingLengthOf(20);
        }
        if (fromApiJsonHelper.parameterExists("chequeDate", element)) {
          LocalDate chequeDate = fromApiJsonHelper.extractLocalDateNamed("chequeDate", element);
          baseDataValidator.reset().parameter("chequeDate").value(chequeDate).notBlank();
        }
        if (fromApiJsonHelper.parameterExists("bankName", element)) {
          String bankName = fromApiJsonHelper.extractStringNamed("bankName", element);
          baseDataValidator
              .reset()
              .parameter("bankName")
              .value(bankName)
              .notBlank()
              .notExceedingLengthOf(100);
        }
        if (fromApiJsonHelper.parameterExists("branchName", element)) {
          String branchName = fromApiJsonHelper.extractStringNamed("branchName", element);
          baseDataValidator
              .reset()
              .parameter("branchName")
              .value(branchName)
              .notBlank()
              .notExceedingLengthOf(100);
        }
      }
    }

    throwExceptionIfValidationWarningsExist(dataValidationErrors);
  }
  public void validateForCreatePartnerGame(final String json) {
    if (StringUtils.isBlank(json)) {
      throw new InvalidJsonException();
    }

    final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
    fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParameters);

    final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
    final DataValidatorBuilder baseDataValidator =
        new DataValidatorBuilder(dataValidationErrors).resource("media.settlement");

    final JsonElement element = fromApiJsonHelper.parse(json);

    final Long partnerName = fromApiJsonHelper.extractLongNamed("partnerName", element);
    baseDataValidator.reset().parameter("partnerName").value(partnerName).notBlank();

    final Long gamePlaySource = fromApiJsonHelper.extractLongNamed("gamePlaySource", element);
    baseDataValidator.reset().parameter("gamePlaySource").value(gamePlaySource).notBlank();

    final Long royaltyValue = fromApiJsonHelper.extractLongNamed("royaltyValue", element);
    baseDataValidator.reset().parameter("royaltyValue").value(royaltyValue).notBlank();

    final Long royaltySequence = fromApiJsonHelper.extractLongNamed("royaltySequence", element);
    baseDataValidator.reset().parameter("royaltySequence").value(royaltySequence).notBlank();

    throwExceptionIfValidationWarningsExist(dataValidationErrors);

    final JsonArray gameMediaPartnerDataArray =
        fromApiJsonHelper.extractJsonArrayNamed("gameMediaPartnerData", element);
    String[] gameMediaPartnerDataAttributes = null;
    gameMediaPartnerDataAttributes = new String[gameMediaPartnerDataArray.size()];
    int gameMediaPartnerDataSize = gameMediaPartnerDataArray.size();
    baseDataValidator
        .reset()
        .parameter(null)
        .value(gameMediaPartnerDataSize)
        .integerGreaterThanZero();

    for (int i = 0; i < gameMediaPartnerDataArray.size(); i++) {
      gameMediaPartnerDataAttributes[i] = gameMediaPartnerDataArray.get(i).toString();
    }

    for (String singleGameMediaPartnerData : gameMediaPartnerDataAttributes) {

      final JsonElement elements = fromApiJsonHelper.parse(singleGameMediaPartnerData);

      final LocalDate gDate = fromApiJsonHelper.extractLocalDateNamed("gDate", elements);
      baseDataValidator.reset().parameter("gDate").value(gDate).notBlank();

      if (fromApiJsonHelper.parameterExists("game", elements)) {
        final String game = fromApiJsonHelper.extractStringNamed("game", elements);
        baseDataValidator.reset().parameter("game").value(game).notBlank();
      } else if (fromApiJsonHelper.parameterExists("gameL", elements)) {
        final String gameL = fromApiJsonHelper.extractStringNamed("gameL", elements);
        baseDataValidator.reset().parameter("gameL").value(gameL).notBlank();
      }

      final BigDecimal overwriteRoyaltyValue =
          fromApiJsonHelper.extractBigDecimalWithLocaleNamed("overwriteRoyaltyValue", elements);
      baseDataValidator
          .reset()
          .parameter("overwriteRoyaltyValue")
          .value(overwriteRoyaltyValue)
          .notBlank();

      final Long playSource = fromApiJsonHelper.extractLongNamed("playSource", elements);
      baseDataValidator.reset().parameter("playSource").value(playSource).notBlank();

      final BigDecimal price =
          fromApiJsonHelper.extractBigDecimalWithLocaleNamed("price", elements);
      baseDataValidator.reset().parameter("price").value(price).notBlank();

      final Long sequence = fromApiJsonHelper.extractLongNamed("sequence", elements);
      baseDataValidator.reset().parameter("sequence").value(sequence).notBlank();

      throwExceptionIfValidationWarningsExist(dataValidationErrors);
    }
  }
  public void validateForCreate(final String json) {
    if (StringUtils.isBlank(json)) {
      throw new InvalidJsonException();
    }

    final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
    fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParameters);

    final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
    final DataValidatorBuilder baseDataValidator =
        new DataValidatorBuilder(dataValidationErrors).resource("media.settlement");

    final JsonElement element = fromApiJsonHelper.parse(json);

    /*final String partnerType = fromApiJsonHelper.extractStringNamed("partnerType", element);
    baseDataValidator.reset().parameter("partnerType").value(partnerType).notBlank().notExceedingLengthOf(50);

    final String mediaCategory = fromApiJsonHelper.extractStringNamed("mediaCategory", element);
    baseDataValidator.reset().parameter("mediaCategory").value(mediaCategory).notBlank().notExceedingLengthOf(50);*/

    final String partnerName = fromApiJsonHelper.extractStringNamed("partnerName", element);
    baseDataValidator
        .reset()
        .parameter("partnerName")
        .value(partnerName)
        .notBlank()
        .notExceedingLengthOf(100);

    final String partnerAddress = fromApiJsonHelper.extractStringNamed("partnerAddress", element);
    baseDataValidator
        .reset()
        .parameter("partnerAddress")
        .value(partnerAddress)
        .notBlank()
        .notExceedingLengthOf(255);

    final BigDecimal externalId =
        fromApiJsonHelper.extractBigDecimalWithLocaleNamed("externalId", element);
    baseDataValidator.reset().parameter("externalId").value(externalId).notBlank();

    final String contactNum = fromApiJsonHelper.extractStringNamed("contactNum", element);
    baseDataValidator
        .reset()
        .parameter("contactNum")
        .value(contactNum)
        .notBlank()
        .notExceedingLengthOf(11);

    final String emailId = fromApiJsonHelper.extractStringNamed("emailId", element);
    baseDataValidator
        .reset()
        .parameter("emailId")
        .value(emailId)
        .notBlank()
        .notExceedingLengthOf(100);

    if (fromApiJsonHelper.parameterExists("currencyCode", element)) {
      final BigDecimal currencyCode =
          fromApiJsonHelper.extractBigDecimalWithLocaleNamed("currencyCode", element);
      baseDataValidator
          .reset()
          .parameter("currencyCode")
          .value(currencyCode)
          .notBlank()
          .notExceedingLengthOf(255);
    }

    /*final String country = fromApiJsonHelper.extractStringNamed("country", element);
    baseDataValidator.reset().parameter("country").value(country).notBlank().notExceedingLengthOf(50);*/

    if (fromApiJsonHelper.parameterExists("currencyId", element)) {
      final Long currencyId = fromApiJsonHelper.extractLongNamed("currencyId", element);
      baseDataValidator.reset().parameter("currencyId").value(currencyId).notBlank();
    }

    if (fromApiJsonHelper.parameterExists("chData", element)) {

      final JsonArray chDataArray = fromApiJsonHelper.extractJsonArrayNamed("chData", element);

      String[] chStringArray = new String[chDataArray.size()];
      /*int chStringArraySize = chDataArray.size();*/
      /*baseDataValidator.reset().parameter(null).value(chStringArraySize).integerGreaterThanZero();*/

      for (int i = 0; i < chDataArray.size(); i++) {
        chStringArray[i] = chDataArray.get(i).toString();
      }

      for (String s : chStringArray) {

        final JsonElement el = fromApiJsonHelper.parse(s);
        final String channelPartnerName =
            fromApiJsonHelper.extractStringNamed("channelPartnerName", el);
        baseDataValidator
            .reset()
            .parameter("channelPartnerName")
            .value(channelPartnerName)
            .notBlank();

        /*final String channelPartnerAddress = fromApiJsonHelper.extractStringNamed("channelPartnerAddress", el);
        baseDataValidator.reset().parameter("channelPartnerAddress").value(channelPartnerAddress).notBlank();
        throwExceptionIfValidationWarningsExist(dataValidationErrors);*/
      }
    }

    throwExceptionIfValidationWarningsExist(dataValidationErrors);
  }