/*
(non-Javadoc)

@see com.impetus.kundera.validation.rules.AbstractEntityRule#validate(java .lang.Class)
349106
@Override
    public void validate(Class<?> clazz) {

        if (log.isDebugEnabled())
            log.debug("Validating " + clazz.getName());

        // Is Entity?
        if (!checkValidClass(clazz)) {

            throw new RuleValidationException(clazz.getName() + " is not a valid jpa entity.");
        }

        // must have a default no-argument constructor
        boolean flag = false;
        try {
            Constructor[] constructors = clazz.getDeclaredConstructors();
            for (Constructor constructor : constructors) {
                if ((Modifier.isPublic(constructor.getModifiers()) || Modifier.isProtected(constructor.getModifiers()))
                    && constructor.getParameterTypes().length == 0) {
                    flag = true;
                    break;
                }
            }
            if (!flag) {
                throw new Exception();
            }
        } catch (Exception e) {
            throw new RuleValidationException(clazz.getName()
                + " must have a default public or protected no-argument constructor.");
        }
    }
297360
@SuppressWarnings("unchecked")
	@Override
	protected void performValidation(String path, Object value, List<ValidationResult> results) {
		String name = path != null ? path : "value";
		value = ObjectReader.getValue(value);

		super.performValidation(path, value, results);

		if (value == null)
			return;

		if (value instanceof List<?>) {
			List<Object> list = (List<Object>) value;
			int index = 0;
			for (Object element : list) {
				String elementPath = path == null || path.length() == 0 ? Integer.toString(index) : path + "." + index;
				performTypeValidation(elementPath, _valueType, element, results);
				index++;
			}
		} else if (value.getClass().isArray()) {
			int length = Array.getLength(value);
			for (int index = 0; index < length; index++) {
				Object element = Array.get(value, index);
				String elementPath = path == null || path.length() == 0 ? Integer.toString(index) : path + "." + index;
				performTypeValidation(elementPath, _valueType, element, results);
				index++;
			}
		} else {
			results.add(new ValidationResult(path, ValidationResultType.Error, "VALUE_ISNOT_ARRAY",
					name + " type must be List or Array", "List", value.getClass()));
		}
	}
120144
private ValidationResult isValidClassForType(Class<?> clazz, SoyType type) {
    // Exit early if the class is primitive and the type is nullable -- that's not allowed.
    // Then remove null from the type.  This allows us to accept precise params for nullable
    // types, e.g, for int|null we can allow IntegerData (which will be passed as 'null').
    if (SoyTypes.isNullable(type) && Primitives.allPrimitiveTypes().contains(clazz)) {
      return ValidationResult.forNullToPrimitive(type);
    }
    // Also exit early if the type is a VE, since those aren't allowed as params.
    if (SoyTypes.isKindOrUnionOfKind(type, SoyType.Kind.VE)
        || SoyTypes.isKindOrUnionOfKind(type, SoyType.Kind.VE_DATA)) {
      return ValidationResult.ve(type);
    }

    ImmutableSet<Class<?>> expectedClasses = null;
    GenericDescriptor expectedDescriptor = null;
    type = SoyTypes.tryRemoveNull(type);
    switch (type.getKind()) {
      case ANY:
      case UNKNOWN:
        expectedClasses = UNKNOWN_TYPES;
        break;
      case ATTRIBUTES:
      case CSS:
      case HTML:
      case URI:
      case TRUSTED_RESOURCE_URI:
      case JS:
        expectedClasses = SANITIZED_TYPES;
        break;
      case BOOL:
        expectedClasses = BOOL_TYPES;
        break;
      case FLOAT:
        expectedClasses = FLOAT_TYPES;
        break;
      case INT:
        expectedClasses = INT_TYPES;
        break;
      case LEGACY_OBJECT_MAP:
        expectedClasses = LEGACY_OBJECT_MAP_TYPES;
        break;
      case LIST:
        expectedClasses = LIST_TYPES;
        break;
      case MAP:
        expectedClasses = MAP_TYPES;
        break;
      case RECORD:
        expectedClasses = RECORD_TYPES;
        break;
      case STRING:
        expectedClasses = STRING_TYPES;
        break;
      case NULL:
        expectedClasses = NULL_TYPES;
        break;
      case PROTO:
        expectedClasses = PROTO_TYPES;
        expectedDescriptor = ((SoyProtoType) type).getDescriptor();
        break;
      case PROTO_ENUM:
        expectedClasses = PROTO_ENUM_TYPES;
        expectedDescriptor = ((SoyProtoEnumType) type).getDescriptor();
        break;
      case UNION:
        // number is a special case, it should work for double and NumberData
        if (type.equals(SoyTypes.NUMBER_TYPE)) {
          expectedClasses = NUMBER_TYPES;
          break;
        }
        // If this is a union, make sure the type is valid for every member.
        // If the type isn't valid for any member, then there's no guarantee this will work
        // for an arbitrary template at runtime.
        ValidationResult result = ValidationResult.valid();
        for (SoyType member : ((UnionType) type).getMembers()) {
          result.merge(isValidClassForType(clazz, member));
        }
        return result;
      case VE:
      case VE_DATA:
        throw new IllegalStateException("This should have been caught above");
      case ERROR:
        throw new IllegalStateException("Cannot have error type from function signature");
    }

    checkState(expectedClasses != null, "expectedClass not set!");
    if (expectedClasses.contains(clazz)) {
      return ValidationResult.valid();
    }
    ImmutableSet<String> expectedDescriptorNames = ImmutableSet.of();
    if (expectedDescriptor instanceof Descriptor) {
      expectedDescriptorNames =
          ImmutableSet.of(JavaQualifiedNames.getClassName((Descriptor) expectedDescriptor));
      if (matchesProtoDescriptor(Message.class, clazz, expectedDescriptor)) {
        return ValidationResult.valid();
      }
    }
    if (expectedDescriptor instanceof EnumDescriptor) {
      expectedDescriptorNames =
          ImmutableSet.of(JavaQualifiedNames.getClassName((EnumDescriptor) expectedDescriptor));
      if (clazz.isEnum()
          && matchesProtoDescriptor(ProtocolMessageEnum.class, clazz, expectedDescriptor)) {
        return ValidationResult.valid();
      }
    }
    // If none of the above conditions match, we failed.
    return ValidationResult.invalid(
        Stream.concat(
                expectedClasses.stream().map(Class::getName), expectedDescriptorNames.stream())
            .collect(toImmutableSet()));
  }
1083052
public static void validate(@NotNull Object bean) {
        Assert.notNull(bean, "bean不能为null");
        Set<ConstraintViolation<Object>> constraintViolations = validator.validate(bean);
        check(constraintViolations);
    }
1281879
@Override
    public boolean validate(Field f) throws RuleValidationException
    {

        boolean checkvalidation = true;
        for (Annotation annotate : f.getDeclaredAnnotations())
        {
            RelationType eruleType = getRuleType(annotate.annotationType().getSimpleName());

            if (eruleType != null)
            {

                switch (eruleType)
                {
                case MANY_TO_MANY:
                    checkvalidation = validateManyToMany(f, annotate);
                    break;
                case MANY_TO_ONE:
                    checkvalidation = validateManyToOne(f, annotate);
                    break;
                case ONE_TO_MANY:
                    checkvalidation = validateOneToMany(f, annotate);
                    break;
                case ONE_TO_ONE:
                    checkvalidation = validateOneToOne(f, annotate);
                    break;

                }

            }
        }

        return checkvalidation;
    }
222724
private void validate() {
        if (host.isEmpty()) {
            throw new IllegalArgumentException("host cannot be null");
        }
        if (catalog == null) {
            throw new IllegalArgumentException("namespace cannot be null");
        }
        if (table == null) {
            throw new IllegalArgumentException("set cannot be null");
        }
        if (portList.isEmpty()) {
            if(port>0){
                port(port);
            }else{
                throw new IllegalArgumentException("port cannot be null");
            }

        }
        if (host.size() != portList.size()) {
            throw new IllegalArgumentException("Host and ports cardinality must be the same");
        }

    }
891599
@SuppressWarnings("unchecked")
   private void verifyBeanValidation(Object as) throws Exception
   {
      if (beanValidation != null)
      {
         ValidatorFactory vf = null;

         try
         {
            vf = beanValidation.getValidatorFactory();
            Validator v = vf.getValidator();

            Collection<String> l = bvGroups;
            if (l == null || l.isEmpty())
               l = Arrays.asList(javax.validation.groups.Default.class.getName());

            Collection<Class<?>> groups = new ArrayList<>();
            for (String clz : l)
            {
               groups.add(Class.forName(clz, true, resourceAdapter.getClass().getClassLoader()));
            }
         
            Set failures = v.validate(as, groups.toArray(new Class<?>[groups.size()]));
         
            if (!failures.isEmpty())
            {
               throw new ConstraintViolationException("Violation for " + as, failures);
            }
         }
         finally
         {
            if (vf != null)
               vf.close();
         }
      }
   }
740651
@Override
    protected void validate(List<TableInfo> tableInfos)
    {
        List listTables = r.db(databaseName).tableList().run(connection);

        for (TableInfo tableInfo : tableInfos)
        {
            try
            {
                if (!listTables.contains(tableInfo.getTableName()))
                {
                    throw new SchemaGenerationException("Table: " + tableInfo.getTableName() + " does not exist ");
                }
            }
            catch (Exception e)
            {
                logger.error("Error while validating tables, Caused by: " + e.getMessage());
                throw new KunderaException("Error while validating tables, Caused by: " + e.getMessage());
            }
        }
    }
974684
@Override
	public void validate(final List<Diagnostic> diags) {
		// Validate each row.
		List beanList = this.getBeanList();
		WComponent row = getRepeatedComponent();

		for (int i = 0; i < beanList.size(); i++) {
			Object rowData = beanList.get(i);
			UIContext rowContext = getRowContext(rowData, i);

			UIContextHolder.pushContext(rowContext);

			try {
				row.validate(diags);
			} finally {
				UIContextHolder.popContext();
			}
		}
	}
131687
@Override
  public String validateInProperty(String unit, String property) {
		assert checkStringParam(unit) : paramError("validate", "unit", "must not be null or empty");
		assert checkStringParam(property) : paramError("validateInProperty", "property", "must not be null or empty");
		try {
			Term term = new ExpressionParser(model).parse(unit);
			Canonical can = new Converter(model, handlers).convert(term);
			String cu = new ExpressionComposer().compose(can, false);
			if (can.getUnits().size() == 1) {
					if (property.equals(can.getUnits().get(0).getBase().getProperty()))
						return null;
					else
						return "unit "+unit+" is of the property type "+can.getUnits().get(0).getBase().getProperty()+" ("+cu+"), not "+property+" as required.";
			}
			// defined special case
			if ("concentration".equals(property) && ("g/L".equals(cu) || "mol/L".equals(cu)))
				return null;
			
			return "unit "+unit+" has the base units "+cu+", and are not from the property "+property+" as required.";
		} catch (Exception e) {
			return e.getMessage();
		}
	}
15351
@Override
  public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    if (pvalue == null) {
      return true;
    }
    try {
      final String field1Value =
          getDomainOf(BeanPropertyReaderUtil.getNullSaveStringProperty(pvalue, field1Name));
      final String field2Value =
          getDomainOf(BeanPropertyReaderUtil.getNullSaveStringProperty(pvalue, field2Name));
      if (!StringUtils.equals(field1Value, field2Value)) {
        switchContext(pcontext);
        return false;
      }
      return true;
    } catch (final Exception ignore) {
      switchContext(pcontext);
      return false;
    }
  }
1050534
@Override
    public boolean validate(Field field, Object fieldValue, IRule... rules) throws RuleValidationException
    {

        if (rules == null)
        {
            return super.validate(field, fieldValue, this.ruleFactory.getJpaRules());
        }
        
        else
        {
            return super.validate(field, fieldValue, rules);
        }

    }
57358
protected void validateEntityIntegrityConstraint(Object entity, DAOMode mode, DAOValidatorEvaluationTime validationTime) {

		// Validation des contraintes d'integrites
		JSR303ValidatorEngine.getDefaultInstance().validate(entity);
	}
1370108
def validate( self ):
        """"""
        klass = self.__class__

        for name in klass._fields:
            self.validate_field( name )
        return
275814
@Override
    public org.fcrepo.server.types.gen.Validation validate(String pid,
                                                           String asOfDateTime) {
        assertInitialized();
        try {
            MessageContext ctx = context.getMessageContext();
            return TypeUtility
                    .convertValidationToGenValidation(m_management.validate(ReadOnlyContext
                                                                                        .getSoapContext(ctx),
                                                                                pid,
                                                                                DateUtility
                                                                                        .parseDateOrNull(asOfDateTime)));
        } catch (Throwable th) {
            LOG.error("Error validating", th);
            throw CXFUtility.getFault(th);
        } finally {
            LOG.debug("end: validate");
        }
    }
797790
protected void validate(final CmsEntity entity) {

        if (!m_validating) {
            m_validating = true;
            m_contentService.validateEntity(entity, new AsyncCallback<CmsValidationResult>() {

                public void onFailure(Throwable caught) {

                    // can be ignored
                }

                public void onSuccess(CmsValidationResult result) {

                    displayValidation(entity.getId(), result);
                }
            });
        }
    }
1184450
public void validate() {
    StringBuilder validationErrorBuilder = new StringBuilder("Process engine configuration is invalid: \n");
    boolean isValid = true;    
    
    if(datasourceJndiName == null || datasourceJndiName.isEmpty()) {
      isValid = false;
      validationErrorBuilder.append(" property 'datasource' cannot be null \n");      
    }
    if(engineName == null || engineName.isEmpty()) {
      isValid = false;
      validationErrorBuilder.append(" property 'engineName' cannot be null \n");
    }

    for (int i = 0; i < pluginConfigurations.size(); i++) {
      ProcessEnginePluginXml pluginConfiguration = pluginConfigurations.get(i);
      if (pluginConfiguration.getPluginClass() == null || pluginConfiguration.getPluginClass().isEmpty()) {
        isValid = false;
        validationErrorBuilder.append(" property 'class' in plugin[" + i + "] cannot be null \n");
      }
    }
    
    if(!isValid) {
      throw new ProcessEngineException(validationErrorBuilder.toString());
    }
  }