Validate export arguments

@param t class to validate
@return validation result
549176
<T> boolean isExportEntityInvalid(final List<T> t) {
        return (BasicCollectionUtils.isEmpty(t) || isExportEntityInvalid(t.get(0)));
    }
556392
@Override
    public ValidationResult validate(PMContext ctx) {
        final ValidationResult res = new ValidationResult();
        final String fieldvalue = (String) ctx.getFieldValue();
        res.setSuccessful(true);
        if (!isName(fieldvalue)) {
            res.setSuccessful(false);
            res.getMessages().add(MessageFactory.error(ctx.getEntity(), ctx.getField(), get("msg", "")));
        }
        return res;
    }
107265
public <T> FluentValidator on(T t) {
        MultiValidatorElement multiValidatorElement = doOn(t);
        LOGGER.debug(multiValidatorElement + " will be performed");
        lastAddCount = multiValidatorElement.size();
        return this;
    }
774392
private static ValidationResult validateFormatStringParameter(
      ExpressionTree formatStringTree,
      Symbol formatStringSymbol,
      List<? extends ExpressionTree> args,
      VisitorState state) {
    if (!isFormatStringParameter(formatStringSymbol, state)) {
      return ValidationResult.create(
          null,
          String.format(
              "Format strings must be compile time constants or parameters annotated "
                  + "@FormatString: %s",
              formatStringTree));
    }

    List<VarSymbol> ownerParams = ((MethodSymbol) formatStringSymbol.owner).getParameters();
    int ownerFormatStringIndex = ownerParams.indexOf(formatStringSymbol);

    ImmutableList.Builder<Type> ownerFormatArgTypesBuilder = ImmutableList.builder();
    for (VarSymbol paramSymbol :
        ownerParams.subList(ownerFormatStringIndex + 1, ownerParams.size())) {
      ownerFormatArgTypesBuilder.add(paramSymbol.type);
    }
    ImmutableList<Type> ownerFormatArgTypes = ownerFormatArgTypesBuilder.build();

    Types types = state.getTypes();
    ImmutableList.Builder<Type> calleeFormatArgTypesBuilder = ImmutableList.builder();
    for (ExpressionTree formatArgExpression : args) {
      calleeFormatArgTypesBuilder.add(types.erasure(((JCExpression) formatArgExpression).type));
    }
    ImmutableList<Type> calleeFormatArgTypes = calleeFormatArgTypesBuilder.build();

    if (ownerFormatArgTypes.size() != calleeFormatArgTypes.size()) {
      return ValidationResult.create(
          null,
          String.format(
              "The number of format arguments passed "
                  + "with an @FormatString must match the number of format arguments in the "
                  + "@FormatMethod header where the format string was declared.\n\t"
                  + "Format args passed: %d\n\tFormat args expected: %d",
              calleeFormatArgTypes.size(), ownerFormatArgTypes.size()));
    } else {
      for (int i = 0; i < calleeFormatArgTypes.size(); i++) {
        if (!ASTHelpers.isSameType(
            ownerFormatArgTypes.get(i), calleeFormatArgTypes.get(i), state)) {
          return ValidationResult.create(
              null,
              String.format(
                  "The format argument types passed "
                      + "with an @FormatString must match the types of the format arguments in "
                      + "the @FormatMethod header where the format string was declared.\n\t"
                      + "Format arg types passed: %s\n\tFormat arg types expected: %s",
                  calleeFormatArgTypes.toArray(), ownerFormatArgTypes.toArray()));
        }
      }
    }

    // Format string usage was valid.
    return null;
  }
1228153
public static ValidationResult validateClassName(String className)
   {
      if (Strings.isNullOrEmpty(className))
         return new ValidationResult(ERROR, Messages.notNullOrEmpty(CLASS_NAME));
      int indexOfDot = className.lastIndexOf(".");
      if (indexOfDot == -1)
      {
         return validateIdentifier(className, CLASS_NAME);
      }
      else
      {
         String packageSequence = className.substring(0, indexOfDot);
         ValidationResult result = validatePackageName(packageSequence);
         if (!result.getType().equals(ResultType.INFO))
         {
            return result;
         }
         String classSequence = className.substring(indexOfDot + 1);
         return validateIdentifier(classSequence, CLASS_NAME);
      }
   }
704956
public static Report validate(final Properties props, final List<Property> properties) {
        final Report report = new Report();
        validate(props, report, properties, null);
        return report;
    }
945656
@Override
	public List<Diagnostic> validate(final List<Diagnostic> diags) {
		if (!isValid()) {
			List<Serializable> argList = getMessageArguments();
			Serializable[] args = argList.toArray(new Serializable[argList.size()]);

			diags.add(new DiagnosticImpl(Diagnostic.ERROR, input, getErrorMessage(), args));
		}

		return diags;
	}
177803
private <T> String format(final T t,
                              final IClassContainer container) {
        final List<ExportContainer> exportContainers = extractExportContainers(t, container);

        final String resultValues = exportContainers.stream()
                .map(c -> convertFieldValue(container.getField(c.getExportName()), c))
                .collect(Collectors.joining(", "));

        return "(" + resultValues + ")";
    }
725474
public <T> FluentValidator onEach(T[] t, final Validator<T> v) {
        Preconditions.checkNotNull(v, "Validator should not be NULL");
        if (ArrayUtil.isEmpty(t)) {
            lastAddCount = 0;
            return this;
        }

        return onEach(Arrays.asList(t), v);
    }
519619
@Override
	public boolean validate(final Problems problems, final String compName, final String text) {
		boolean invalid = text.contains(File.separator) || text.contains(File.pathSeparator);
		if (!invalid && Utilities.isWindows()) {
			invalid = text.contains(":");
		}
		final String result = invalid
				? ValidationBundle.getMessage(IllegalCharactersInFileNameValidator.class, "ERR_INVALID_FILE_NAME", compName, text)
				: null; // NOI18N
		if (result != null) {
			problems.add(result);
		}
		return !invalid;
	}
717946
@Override
	public boolean validate(final Problems problems, final String compName, final String model) {
		final String[] parts = model.split("\\.");
		boolean hasIntParts = false;
		boolean hasNonIntParts = false;
		if (model.indexOf(" ") > 0 || model.indexOf("\t") > 0) {
			problems.add(ValidationBundle.getMessage(ValidHostNameOrIPValidator.class, "HOST_MAY_NOT_CONTAIN_WHITESPACE", compName, model)); // NOI18N
			return false;
		}
		if (parts.length == 0) { // the string "."
			problems.add(ValidationBundle.getMessage(ValidHostNameOrIPValidator.class, "INVALID_HOST_OR_IP", compName, model)); // NOI18N
			return false;
		}
		for (int i = 0; i < parts.length; i++) {
			String s = parts[i];
			if (i == parts.length - 1 && s.contains(":")) { // NOI18N
				final String[] partAndPort = s.split(":"); // NOI18N
				if (partAndPort.length > 2) {
					problems.add(ValidationBundle.getMessage(ValidHostNameOrIPValidator.class, "TOO_MANY_COLONS", compName, model)); // NOI18N
					return false;
				}
				if (partAndPort.length == 0) { // the string ":"
					problems.add(ValidationBundle.getMessage(ValidHostNameOrIPValidator.class, "INVALID_HOST_OR_IP", compName, model)); // NOI18N
					return false;
				}
				s = partAndPort[0];
				if (partAndPort.length == 2) {
					try {
						Integer.parseInt(partAndPort[1]);
					} catch (final NumberFormatException nfe) {
						problems.add(ValidationBundle.getMessage(ValidHostNameOrIPValidator.class, "INVALID_PORT", compName, partAndPort[1])); // NOI18N
						return false;
					}
				}
			}
			try {
				Integer.parseInt(s);
				hasIntParts = true;
			} catch (final NumberFormatException nfe) {
				hasNonIntParts = true;
			}
			if (hasIntParts && hasNonIntParts) {
				problems.add(
						ValidationBundle.getMessage(ValidHostNameOrIPValidator.class, "ADDRESS_CONTAINS_INT_AND_NON_INT_LABELS", compName, model)); // NOI18N
				return false;
			}
		}

		final boolean validHost = hasNonIntParts && this.hostVal.validate(problems, compName, model);
		final boolean validIp = hasIntParts && this.ipVal.validate(problems, compName, model);
		return validHost || validIp;
	}
404430
@Override
	public List<ParsingError> doValidate() {

		List<ParsingError> result = new ArrayList<> ();
		if( Utils.isEmptyOrWhitespaces( this.targetId ))
			result.add( error( ErrorCode.CMD_INVALID_TARGET_ID, value( this.targetId )));

		Instance resolvedInstance;
		if(( resolvedInstance = this.context.resolveInstance( this.scopedInstancePath )) == null)
			result.add( error( ErrorCode.CMD_NO_MATCHING_INSTANCE, instance( this.scopedInstancePath )));
		else if( ! InstanceHelpers.isTarget( resolvedInstance ))
			result.add( error( ErrorCode.CMD_NOT_A_SCOPED_INSTANCE ));

		return result;
	}
737328
public static <T> T validateNull(T value, String errorMsgTemplate, Object... params) throws ValidateException {
		if (isNotNull(value)) {
			throw new ValidateException(errorMsgTemplate, params);
		}
		return value;
	}
311291
public static <T extends MPBase> boolean validate(T objectToValidate) throws MPValidationException {
        Collection<ValidationViolation> colViolations = validate(new Vector<ValidationViolation>(), objectToValidate);
        if (!colViolations.isEmpty()) {
            throw new MPValidationException(colViolations);
        }
        return true;
    }
1188863
@Override
    public ValidationResult validate(PMContext ctx) {
        final ValidationResult res = new ValidationResult();
        final Object fieldvalue = ctx.getFieldValue();
        res.setSuccessful(fieldvalue != null);
        if (!res.isSuccessful()) {
            res.getMessages().add(MessageFactory.error(
                    ctx.getEntity(), ctx.getField(),
                    get("msg", "pm.validator.not.null"),
                    ctx.getField().getId()));
        }
        return res;
    }
997930
public static<T extends ParamValidator> T getValidator(Class<T> clazz, boolean required) {

        List<ParamValidator> validators = validatorsMap.get(clazz);
        if (validators != null) {

            if (required) {
                return (T)validators.get(0);
            }

            return (T)validators.get(1);
        }

        return null;
    }
546917
protected void validate(String operationType) throws Exception
	{
		super.validate(operationType);

		MPSLong exporter_id_validator = new MPSLong();
		exporter_id_validator.validate(operationType, exporter_id, "\"exporter_id\"");
		
		MPSLong priority_validator = new MPSLong();
		priority_validator.validate(operationType, priority, "\"priority\"");
		
		MPSLong timestamp_validator = new MPSLong();
		timestamp_validator.validate(operationType, timestamp, "\"timestamp\"");
		
		MPSString hostname_validator = new MPSString();
		hostname_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		hostname_validator.validate(operationType, hostname, "\"hostname\"");
		
		MPSString process_name_validator = new MPSString();
		process_name_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		process_name_validator.validate(operationType, process_name, "\"process_name\"");
		
		MPSString module_validator = new MPSString();
		module_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		module_validator.validate(operationType, module, "\"module\"");
		
		MPSString type_validator = new MPSString();
		type_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		type_validator.validate(operationType, type, "\"type\"");
		
		MPSString syslog_msg_validator = new MPSString();
		syslog_msg_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 2000);
		syslog_msg_validator.validate(operationType, syslog_msg, "\"syslog_msg\"");
		
		MPSLong sequence_no_validator = new MPSLong();
		sequence_no_validator.validate(operationType, sequence_no, "\"sequence_no\"");
		
		MPSLong datarecord_rx_time_validator = new MPSLong();
		datarecord_rx_time_validator.validate(operationType, datarecord_rx_time, "\"datarecord_rx_time\"");
		
		MPSBoolean decoded_validator = new MPSBoolean();
		decoded_validator.validate(operationType, decoded, "\"decoded\"");
		
		MPSString group_name_validator = new MPSString();
		group_name_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		group_name_validator.validate(operationType, group_name, "\"group_name\"");
		
		MPSString sessionId_validator = new MPSString();
		sessionId_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		sessionId_validator.validate(operationType, sessionId, "\"sessionId\"");
		
		MPSString username_validator = new MPSString();
		username_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		username_validator.validate(operationType, username, "\"username\"");
		
		MPSString clientip_validator = new MPSString();
		clientip_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		clientip_validator.validate(operationType, clientip, "\"clientip\"");
		
		MPSString vserverip_validator = new MPSString();
		vserverip_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		vserverip_validator.validate(operationType, vserverip, "\"vserverip\"");
		
		MPSString vserverport_validator = new MPSString();
		vserverport_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		vserverport_validator.validate(operationType, vserverport, "\"vserverport\"");
		
		MPSString nat_ip_validator = new MPSString();
		nat_ip_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		nat_ip_validator.validate(operationType, nat_ip, "\"nat_ip\"");
		
		MPSString sourceip_validator = new MPSString();
		sourceip_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		sourceip_validator.validate(operationType, sourceip, "\"sourceip\"");
		
		MPSString sourceport_validator = new MPSString();
		sourceport_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		sourceport_validator.validate(operationType, sourceport, "\"sourceport\"");
		
		MPSString destinationip_validator = new MPSString();
		destinationip_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		destinationip_validator.validate(operationType, destinationip, "\"destinationip\"");
		
		MPSString destinationport_validator = new MPSString();
		destinationport_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		destinationport_validator.validate(operationType, destinationport, "\"destinationport\"");
		
		MPSString starttime_validator = new MPSString();
		starttime_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		starttime_validator.validate(operationType, starttime, "\"starttime\"");
		
		MPSString endtime_validator = new MPSString();
		endtime_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		endtime_validator.validate(operationType, endtime, "\"endtime\"");
		
		MPSString duration_validator = new MPSString();
		duration_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		duration_validator.validate(operationType, duration, "\"duration\"");
		
		MPSString totalBytesSend_validator = new MPSString();
		totalBytesSend_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		totalBytesSend_validator.validate(operationType, totalBytesSend, "\"totalBytesSend\"");
		
		MPSString totalBytesRecv_validator = new MPSString();
		totalBytesRecv_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		totalBytesRecv_validator.validate(operationType, totalBytesRecv, "\"totalBytesRecv\"");
		
		MPSString totalCompressedBytesSend_validator = new MPSString();
		totalCompressedBytesSend_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		totalCompressedBytesSend_validator.validate(operationType, totalCompressedBytesSend, "\"totalCompressedBytesSend\"");
		
		MPSString totalCompressedBytesRecv_validator = new MPSString();
		totalCompressedBytesRecv_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		totalCompressedBytesRecv_validator.validate(operationType, totalCompressedBytesRecv, "\"totalCompressedBytesRecv\"");
		
		MPSString compressionRatioSend_validator = new MPSString();
		compressionRatioSend_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		compressionRatioSend_validator.validate(operationType, compressionRatioSend, "\"compressionRatioSend\"");
		
		MPSString compressionRatioRecv_validator = new MPSString();
		compressionRatioRecv_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		compressionRatioRecv_validator.validate(operationType, compressionRatioRecv, "\"compressionRatioRecv\"");
		
		MPSString domainname_validator = new MPSString();
		domainname_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		domainname_validator.validate(operationType, domainname, "\"domainname\"");
		
		MPSString applicationName_validator = new MPSString();
		applicationName_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		applicationName_validator.validate(operationType, applicationName, "\"applicationName\"");
		
		MPSString browserType_validator = new MPSString();
		browserType_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		browserType_validator.validate(operationType, browserType, "\"browserType\"");
		
		MPSString clientType_validator = new MPSString();
		clientType_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		clientType_validator.validate(operationType, clientType, "\"clientType\"");
		
		MPSString logoutMethod_validator = new MPSString();
		logoutMethod_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		logoutMethod_validator.validate(operationType, logoutMethod, "\"logoutMethod\"");
		
		MPSString vpnaccess_validator = new MPSString();
		vpnaccess_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		vpnaccess_validator.validate(operationType, vpnaccess, "\"vpnaccess\"");
		
		MPSString deniedURL_validator = new MPSString();
		deniedURL_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		deniedURL_validator.validate(operationType, deniedURL, "\"deniedURL\"");
		
		MPSString deniedByPolicy_validator = new MPSString();
		deniedByPolicy_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		deniedByPolicy_validator.validate(operationType, deniedByPolicy, "\"deniedByPolicy\"");
		
		MPSString remote_host_validator = new MPSString();
		remote_host_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		remote_host_validator.validate(operationType, remote_host, "\"remote_host\"");
		
		MPSString xdatalen_validator = new MPSString();
		xdatalen_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		xdatalen_validator.validate(operationType, xdatalen, "\"xdatalen\"");
		
		MPSString xdata_validator = new MPSString();
		xdata_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		xdata_validator.validate(operationType, xdata, "\"xdata\"");
		
		MPSString last_contact_validator = new MPSString();
		last_contact_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		last_contact_validator.validate(operationType, last_contact, "\"last_contact\"");
		
		MPSString httpResourceName_validator = new MPSString();
		httpResourceName_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		httpResourceName_validator.validate(operationType, httpResourceName, "\"httpResourceName\"");
		
		MPSString licenselmt_validator = new MPSString();
		licenselmt_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		licenselmt_validator.validate(operationType, licenselmt, "\"licenselmt\"");
		
		MPSString connectionId_validator = new MPSString();
		connectionId_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		connectionId_validator.validate(operationType, connectionId, "\"connectionId\"");
		
		MPSString clisecexp_validator = new MPSString();
		clisecexp_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		clisecexp_validator.validate(operationType, clisecexp, "\"clisecexp\"");
		
		MPSString eval_value_validator = new MPSString();
		eval_value_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		eval_value_validator.validate(operationType, eval_value, "\"eval_value\"");
		
		MPSString httpResourcesAccessed_validator = new MPSString();
		httpResourcesAccessed_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		httpResourcesAccessed_validator.validate(operationType, httpResourcesAccessed, "\"httpResourcesAccessed\"");
		
		MPSString nonhttpServicesAccessed_validator = new MPSString();
		nonhttpServicesAccessed_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		nonhttpServicesAccessed_validator.validate(operationType, nonhttpServicesAccessed, "\"nonhttpServicesAccessed\"");
		
		MPSString totalTCPconnections_validator = new MPSString();
		totalTCPconnections_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		totalTCPconnections_validator.validate(operationType, totalTCPconnections, "\"totalTCPconnections\"");
		
		MPSString totalUDPflows_validator = new MPSString();
		totalUDPflows_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		totalUDPflows_validator.validate(operationType, totalUDPflows, "\"totalUDPflows\"");
		
		MPSString totalPoliciesAllowed_validator = new MPSString();
		totalPoliciesAllowed_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		totalPoliciesAllowed_validator.validate(operationType, totalPoliciesAllowed, "\"totalPoliciesAllowed\"");
		
		MPSString totalPoliciesDenied_validator = new MPSString();
		totalPoliciesDenied_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 255);
		totalPoliciesDenied_validator.validate(operationType, totalPoliciesDenied, "\"totalPoliciesDenied\"");
		
		MPSString id_validator = new MPSString();
		id_validator.setConstraintIsReq(MPSConstants.DELETE_CONSTRAINT, true);
		id_validator.setConstraintIsReq(MPSConstants.MODIFY_CONSTRAINT, true);
		id_validator.validate(operationType, id, "\"id\"");
		
	}