Validates the attribute of the object.
If there is any error, the error message is added to the object.
@param CModel the object being validated
@param Array the attribute being validated
172361
protected function validateAttribute($object,$attribute) {
        $value=$object->$attribute;
        if($this->allowEmpty && $this->isEmpty($value))
            return;
        elseif(!is_array($value)) {
            $message=$this->message!==null?$this->message:Yii::t('P2Module.p2','{attribute} is not valid.');
            $this->addError($object,$attribute,$message);
        }

        $length=count($value);
        if($this->min!==null && $length<$this->min) {
            $message=$this->tooShort!==null?$this->tooShort:Yii::t('P2Module.p2','{attribute} is too short (minimum is {min} entries).');
            $this->addError($object,$attribute,$message,array('{min}'=>$this->min));
        }
        if($this->max!==null && $length>$this->max) {
            $message=$this->tooLong!==null?$this->tooLong:Yii::t('P2Module.p2','{attribute} is too long (maximum is {max} entries).');
            $this->addError($object,$attribute,$message,array('{max}'=>$this->max));
        }
        if($this->is!==null && $length!==$this->is) {
            $message=$this->message!==null?$this->message:Yii::t('P2Module.p2','{attribute} is of the wrong length (should be {length} entries).');
            $this->addError($object,$attribute,$message,array('{length}'=>$this->is));
        }
    }
37102
public void validate() {

        if (CmsStringUtil.isEmpty(getNewPwd())) {
            throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_INVALID_NEWPWD_0));
        }
        if (!getNewPwd().equals(getConfirmation())) {
            throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_NEWPWD_MISMATCH_0));
        }
    }
1338808
public void validateField(final I_CmsFormField field) {

        CmsValidationController validationController = new CmsValidationController(field, createValidationHandler());
        validationController.setFormValidator(m_validatorClass);
        validationController.setFormValidatorConfig(createValidatorConfig());
        startValidation(validationController);
    }
93177
@SuppressWarnings("unchecked")
    private boolean isValid() {

        for (Field<?> field : m_fields) {
            if (!field.isValid()) {
                field.focus();

                return false;
            }
        }
        for (Component c : m_resources) {
            if (c instanceof CmsRemovableFormRow<?>) {
                if (!((CmsRemovableFormRow<CmsPathSelectField>)c).getInput().isValid()) {
                    ((CmsRemovableFormRow<CmsPathSelectField>)c).getInput().focus();
                    return false;
                }
            }
        }
        return true;
    }
132948
public static function validateArray(array $array) {
        $reflection =  new ReflectionClass(get_called_class());
        $allowedValues = $reflection->getConstants();
        foreach($array as $element) {
            if (!in_array($element, $allowedValues)) {
                throw new InvalidArgumentException(sprintf(
                    '%s is not a valid %s',
                    $element,
                    get_called_class()
                ));
            }
        }
    }
41450
public function validateModelId($attribute, $params)
    {
        /** @var ActiveRecord $class */
        $class = Model::findIdentity($this->model_class);
        if ($class === null) {
            $this->addError($attribute, \Yii::t('net_frenzel_communication', 'ERROR_MSG_INVALID_MODEL_ID'));
        } else {
            $model = $class->name;
            if ($model::find()->where(['id' => $this->entity_id]) === false) {
                $this->addError($attribute, \Yii::t('net_frenzel_communication', 'ERROR_MSG_INVALID_MODEL_ID'));
            }
        }
    }
589718
@Override
    protected void initValidation() throws XMLStreamException
    {
        if (hasConfigFlags(CFG_VALIDATE_AGAINST_DTD)
            && !mDtdValidatorSet) {
            /* It's ok to miss it, but it may not be what caller wants. Either
             * way, let's pass the info and continue
             */
            reportProblem(null, ErrorConsts.WT_DT_DECL, ErrorConsts.W_MISSING_DTD, null, null);
        }
    }
645838
public function validate(array $array)
	{
		$messages = [];
		foreach ($this->metadata->fields as $field)
		{
			$value = array_key_exists($field, $array)? $array[$field] : null;
			if (!(($value === null) && $this->metadata->nullables[$field]))
			{
				$validator = $this->getValidator($field);
				if (!$validator->isValid($value))
				{
					$messages[$field] = $validator->getMessages();
				}
			}
		}
		$globalValidator = $this->getValidator(self::GLOBAL_VALIDATOR_KEY);
		if (!$globalValidator->isValid($array))
		{
			$messages[self::GLOBAL_VALIDATOR_KEY] = $globalValidator->getMessages();
		}
		return $messages;
	}
1092977
public function validateTemplate($attribute, array $params)
    {
        if (!isset(self::$config->templates[$this->template])) {
            $this->addError('template', "Unable to find template '{$this->template}'.");
        }
    }
375693
public void attributeDecl(
        String arg0,
        String arg1,
        String arg2,
        String arg3,
        String arg4)
        throws SAXException
    {
        m_handler.attributeDecl(arg0, arg1, arg2, arg3, arg4);
    }
885531
public void validateParameters(CmsObject cms) {

        CmsMessages messages = Messages.get().getBundle(getLocale());
        StringBuffer validationErrors = new StringBuffer();
        if (CmsStringUtil.isEmpty(getParamFolder1())) {
            validationErrors.append(messages.key(Messages.GUI_MERGE_PAGES_VALIDATE_FIRST_FOLDER_0)).append("<br>");
        } else {
            try {
                cms.readResource(getParamFolder1());
            } catch (CmsException e) {
                validationErrors.append(
                    messages.key(Messages.GUI_MERGE_PAGES_VALIDATE_FIRST_FOLDER_1, getParamFolder1())).append("<br>");
            }
        }
        if (CmsStringUtil.isEmpty(getParamFolder2())) {
            validationErrors.append(messages.key(Messages.GUI_MERGE_PAGES_VALIDATE_SECOND_FOLDER_0)).append("<br>");
        } else {
            try {
                cms.readResource(getParamFolder2());
            } catch (CmsException e) {
                validationErrors.append(
                    messages.key(Messages.GUI_MERGE_PAGES_VALIDATE_SECOND_FOLDER_1, getParamFolder2())).append("<br>");
            }
        }
        if (getParamFolder1().equals(getParamFolder2())) {
            validationErrors.append(messages.key(Messages.GUI_MERGE_PAGES_VALIDATE_SAME_FOLDER_0)).append("<br>");
        }

        setErrorMessage(validationErrors.toString());
    }
1031165
private static void validateMappedBy(Attribute attr, Attribute mappedByAttr) {
    if (mappedByAttr != null) {
      if (!isSingleReferenceType(mappedByAttr)) {
        throw new MolgenisDataException(
            format(
                "Invalid mappedBy attribute [%s] data type [%s].",
                mappedByAttr.getName(), mappedByAttr.getDataType()));
      }

      Attribute refAttr = attr.getRefEntity().getAttribute(mappedByAttr.getName());
      if (refAttr == null) {
        throw new MolgenisDataException(
            format(
                "mappedBy attribute [%s] is not part of entity [%s].",
                mappedByAttr.getName(), attr.getRefEntity().getId()));
      }
    }
  }
960544
public static function validateElement(array $element, FormStateInterface $form_state) {
    if ($element['#required'] && $element['#value'] == '_none') {
      $form_state->setError($element, t('@name field is required.', ['@name' => $element['#title']]));
    }

    // Save the value in the element key_column.
    // Note: there is only one item because the field is not multiple value.
    $items = [$element['#key_column'] => $element['#value']];

    $form_state->setValueForElement($element, $items);
  }
149673
private void validate() {
    if (Strings.emptyToNull(random) == null) {
      random = Strings.emptyToNull(getProject().getProperty(SYSPROP_RANDOM_SEED())); 
    }
    
    if (random == null) {
      throw new BuildException("Required attribute 'seed' must not be empty. Look at <junit4:pickseed>.");
    }
    
    long[] seeds = SeedUtils.parseSeedChain(random);
    if (seeds.length < 1) {
      throw new BuildException("Random seed is required.");
    }
    
    if (values.isEmpty() && !allowUndefined) {
      throw new BuildException("No values to pick from and allowUndefined=false.");
    }
  }
99733
public static function validates($attr, $validation) 
    {
        $cls = get_called_class();

        if (!array_key_exists($cls, self::$_validations)) {
            self::$_validations[$cls] = array();
        }

        if (!array_key_exists($attr, self::$_validations[$cls])) {
            self::$_validations[$cls][$attr] = array();
        }

        array_push(self::$_validations[$cls][$attr], $validation);
    }
1191094
protected void addValidators() {

        //Target file ComboBox
        m_target.removeAllValidators();
        m_target.addValidator(new TargetValidator());

        for (I_CmsEditableGroupRow row : m_resourcesGroup.getRows()) {
            FormLayout layout = (FormLayout)(row.getComponent());
            CmsPathSelectField field = (CmsPathSelectField)layout.getComponent(0);
            field.removeAllValidators();
            field.addValidator(new ResourceValidator());
        }
    }
1241937
@SuppressWarnings("unchecked")
    private void validateTable(int targetRow) {
        // TODO pooling of the arrays?
        if (null == this.values) {
            // nothing has been created yet
            int size = (targetRow + 1);
            if (SIZE_TABLE > size) {
                size = SIZE_TABLE;
            }
            this.values = (V[][]) new Object[size][];
        } else if (targetRow >= this.values.length) {
            // this row puts us beyond the current storage
            final int size = (targetRow + 1);
            Object[][] newTable = new Object[size][];
            System.arraycopy(this.values, 0, newTable, 0, this.values.length);
            this.values = (V[][]) newTable;
        } else if (null != this.values[targetRow]) {
            // we already have this row created and are set
            return;
        }
        // need to create the new row in the table
        this.values[targetRow] = (V[]) new Object[SIZE_ROW];
        for (int i = 0; i < SIZE_ROW; i++) {
            this.values[targetRow][i] = (V) NO_VALUE;
        }
    }