Perform validation for a single validator

@param ui the {@link UIObject} to change the stylesheet on
@return true if this validator was successfully applied or false otherwise
960926
protected boolean validate(Validator validator, UIObject ui) {

        if (notifiedWidgets.containsKey(validator))
            ui = notifiedWidgets.get(validator);

        String msg = validator.validate();
        if (msg == null || msg.length() == 0) {
            validationStyles(validator, null, ui, true);
            return true;
        } else {
            validationStyles(validator, msg, ui, false);
            return false;
        }
    }
1082446
@Override
    public void validate() throws OpsGenieClientValidationException {
        super.validate();
        if (name == null && id == null)
            throw OpsGenieClientValidationException.missingMultipleMandatoryProperty(OpsGenieClientConstants.API.NAME, OpsGenieClientConstants.API.ID);
    }
630210
public boolean isValid(MnoHttpClient httpClient) {
		if (uid == null) {
			return false;
		}
		if (isRemoteCheckRequired()) {
			if (this.performRemoteCheck(httpClient)) {
				return true;
			} else {
				return false;
			}
		}
		return true;
	}
924474
@Override
    public ValidationResult<?> validate(final OptionalConfigurationComponent<?> configurationComponent) {
        if (configurationComponent instanceof ValidatingConfigurationComponent) {
            @SuppressWarnings("rawtypes")
            final ValidatingConfigurationComponent<?> validatingComponent = (ValidatingConfigurationComponent) configurationComponent;
            return validatingComponent.validate();
        } else {
            final Class<?> componentClass = configurationComponent.getClass();
            final Validator<?> validator = validators.get(componentClass);
            if (validator != null) {
                @SuppressWarnings({"unchecked", "rawtypes"})
                final ValidationResult<?> validationResult = ((Validator) validator).validate(configurationComponent);
                return validationResult;
            } else {
                throw new IllegalArgumentException("No validator for class " + componentClass.getCanonicalName());
            }
        }
    }
73479
private Boolean validate(final DragAndDropEvent event) {
        final Transferable transferable = event.getTransferable();
        final Component compsource = transferable.getSourceComponent();
        if (!(compsource instanceof AbstractTable)) {
            uiNotification.displayValidationError(getI18n().getMessage(getActionNotAllowedMessage()));
            return false;
        }

        final TableTransferable tabletransferable = (TableTransferable) transferable;

        final AbstractTable<?> source = (AbstractTable<?>) tabletransferable.getSourceComponent();

        if (!validateIfSourceIsTargetTable(source) && !hasTargetUpdatePermission()) {
            return false;
        }

        final Set<Long> deletedEntityByTransferable = source.getSelectedEntitiesByTransferable(tabletransferable);
        if (deletedEntityByTransferable.isEmpty()) {
            final String actionDidNotWork = getI18n().getMessage("message.action.did.not.work");
            uiNotification.displayValidationError(actionDidNotWork);
            return false;
        }

        return true;
    }
282649
function Validation(config) {
    
    var w = config.writer;
    
    var id = 'validation';
    
    $('#'+config.parentId).append('<div id="'+id+'">'+
            '<div id="'+id+'_buttons"><button type="button">Validate</button><button type="button">Clear</button><button type="button">Help</button></div>'+
            '<ul class="validationList"></ul>'+
        '</div>');
    
    w.event('documentLoaded').subscribe(function() {
        validation.clearResult();
    });
    
    w.event('validationInitiated').subscribe(function() {
        var list = $('#'+id+' > ul');
        list.empty();
        list.append(''+
        '<li class="ui-state-default">'+
            '<span class="loading"></span> Validating...'+
        '</li>');
        showValidation();
    });
    
    w.event('documentValidated').subscribe(function(valid, resultDoc, docString) {
        $('#'+id+'_indicator').hide();
        validation.showValidationResult(resultDoc, docString);
    });
    
    // TODO decouple
    function showValidation() {
        w.layout.ui.center.children.layout1.open('south');
        $('#southTabs').tabs('option', 'active', 0);
    }
    
    /**
     * @lends Validation.prototype
     */
    var validation = {};
    
    /**
     * Processes a validation response from the server.
     * @param resultDoc The actual response
     * @param docString The doc string sent to the server for validation  
     */
    validation.showValidationResult = function(resultDoc, docString) {
        var list = $('#'+id+' > ul');
        list.empty();
        
        docString = docString.split('\n')[1]; // remove the xml header
        
        var status = $('status', resultDoc).text();
        
        if (status == 'pass') {
            list.append(''+
                '<li class="ui-state-default">'+
                    '<span class="ui-icon ui-icon-check" style="float: left; margin-right: 4px;"></span>Your document is valid!'+
                '</li>');
        }
        
        $('warning', resultDoc).each(function(index, el) {
            var id = '';
            
            var type = el.nodeName;
            var message = $(this).find('message').text();
            var path = $(this).find('path').text();
            var elementId = $(this).find('elementId').text();
            var column = parseInt($(this).find('column').text());
            
            if (elementId != '') {
                id = elementId;
            } else if (path != '') {
                var editorPath = '';
                var tags = path.split('/');
                for (var i = 0; i < tags.length; i++) {
                    var tag = tags[i];
                    var tagName = tag.match(/^\w+(?=\[)?/);
                    if (tagName != null) {
                        var index = tag.match(/\[(\d+)\]/);
                        if (index === null) {
                            index = 0;
                        } else {
                            index = parseInt(index[1]);
                            index--; // xpath is 1-based and "eq()" is 0-based
                        }
                        editorPath += '*[_tag="'+tagName[0]+'"]:eq('+index+') > ';
                    }
                }
                editorPath = editorPath.substr(0, editorPath.length-3);
                var docEl = $(editorPath, w.editor.getBody());
                id = docEl.attr('id');
            } else if (!isNaN(column)) {
                var docSubstring = docString.substring(0, column);
                var tags = docSubstring.match(/<.*?>/g);
                if (tags != null) {
                    var tag = tags[tags.length-1];
                    id = tag.match(/id="(.*?)"/i);
                    if (id == null) {
                        if (message.search('text not allowed here') != -1) {
                            // find the parent tag
                            var level = 0;
                            for (var i = tags.length-1; i > -1; i--) {
                                tag = tags[i];
                                if (tag.search('/') != -1) {
                                    level++; // closing tag, add a level
                                } else {
                                    level--; // opening tag, remove a level
                                }
                                if (level == -1) {
                                    var match = tag.match(/id="(.*?)"/i);
                                    if (match != null && match[1]) id = match[1];
                                    break;
                                }
                            }
                        } else {
                            var tagMatch = tag.match(/<\/(.*)>/);
                            if (tagMatch != null) {
                                // it's and end tag, so find the matching start tag
                                var tagName = tagMatch[1];
                                for (var i = tags.length-1; i > -1; i--) {
                                    tag = tags[i];
                                    var startTagName = tag.match(/<(.*?)\s/);
                                    if (startTagName != null && startTagName[1] == tagName) {
                                        id = tag.match(/id="(.*?)"/i)[1];
                                        break;
                                    }
                                }
                            } else {
                                // probably entity tag
                            }
                        }
                    } else {
                        id = id[1];
                    }
                } else {
                    // can't find any tags!
                }
            }
            
            var messageParts;
            var messageDivLoc = message.indexOf(';');
            if (messageDivLoc != -1) {
                messageParts = [message.slice(0, messageDivLoc+1), message.slice(messageDivLoc+2)];
            } else {
                messageParts = [message];
            }
            
            var messageHtml = '<li class="'+(type=='warning'?'ui-state-error':'ui-state-highlight')+'">'+
                '<span class="ui-icon '+(type=='warning'?'ui-icon-alert':'ui-icon-info')+'" style="float: left; margin-right: 4px;"></span>'+
                'Path: '+path+'<br/>'+
                'Message: '+messageParts[0];
            if (messageParts[1] !== undefined) {
                messageHtml += ' <span class="message_more">more...</span><span style="display: none;">'+messageParts[1]+'</span>';
            }
            messageHtml += '</li>';
            
            var item = list.append(messageHtml).find('li:last');
            item.find('[class="message_more"]').click(function() {
                $(this).next('span').show();
                $(this).hide();
            });
            
            item.data('id', id);
        });
        
        list.find('li').click(function() {
            var id = $(this).data('id');
            if (id) {
                w.selectStructureTag(id);
            }
        });
        
        showValidation();
    };
    
    validation.clearResult = function() {
        $('#'+id+'_indicator').hide();
        $('#'+id+' > ul').empty();
    };
    

    $('#'+id+'_buttons button:eq(0)').button().click(function() {
        w.delegator.validate();
    });
    $('#'+id+'_buttons button:eq(1)').button().click(function() {
        validation.clearResult();
    });
    $('#'+id+'_buttons button:eq(2)').button({icons: {primary: 'ui-icon-help'}}).click(function() {
        w.dialogManager.show('help', {
            id: 'validation',
            title: 'Validation Help'
        });
    });
    
    // add to writer
    w.validation = validation;
    
    return validation;
}
127625
public static boolean validate(Fragment fragment, IValidationCallback callback) {
		return validate(fragment.getActivity(), fragment, callback);
	}
165617
@SuppressWarnings("deprecation")
    public void validate(final Mapper mapper) {
        new MappingValidator(mapper.getOptions().getObjectFactory()).validate(mapper, this);
    }
719695
@Override
    public void validate() throws OpsGenieClientValidationException {
        super.validate();
        if (username == null && id == null)
            throw OpsGenieClientValidationException.missingMultipleMandatoryProperty(OpsGenieClientConstants.API.USERNAME, OpsGenieClientConstants.API.ID);
    }
1266280
@Override
  public final boolean isValid(final String pvalue, final ConstraintValidatorContext pcontext) {
    if (StringUtils.isEmpty(pvalue)) {
      return true;
    }
    if (pvalue.length() > LENGTH_URL) {
      // url is to long, but that's handled by size annotation
      return true;
    }
    return org.apache.commons.validator.routines.UrlValidator.getInstance().isValid(pvalue);
  }
351226
@Override
  public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    final String valueAsString = Objects.toString(pvalue, null);
    if (StringUtils.isEmpty(valueAsString)) {
      return true;
    }
    if (valueAsString.length() != ISIN_LENGTH) {
      // ISIN size is wrong, but that's handled by size annotation
      return true;
    }
    // calculate and check checksum (ISIN)
    return CHECK_ISIN.isValid(valueAsString);
  }
529424
public function ui(JqueryUI $ui=NULL) {
		if ($ui!==NULL) {
			$this->_ui=$ui;
			$ui->setJs($this);
			$bs=$this->bootstrap();
			if (isset($bs)) {
				$this->conflict();
			}
		}
		return $this->_ui;
	}
1163311
public static boolean validate(Control control) {
        ValidationFacade facade = (ValidationFacade) control.getParent();
        for (ValidatorBase validator : facade.validators) {
            validator.setSrcControl(facade.controlProperty.get());
            validator.validate();
            if (validator.getHasErrors()) {
                facade.activeValidator.set(validator);
                control.pseudoClassStateChanged(PSEUDO_CLASS_ERROR, true);
                return false;
            }
        }
        control.pseudoClassStateChanged(PSEUDO_CLASS_ERROR, false);
        facade.activeValidator.set(null);
        return true;
    }
732371
@Override
    public boolean validate() {
        for (ValidatorBase validator : validators) {
            // source control must be set to allow validators re-usability
            validator.setSrcControl(control);
            validator.validate();
            if (validator.getHasErrors()) {
                activeValidator.set(validator);
                return false;
            }
        }
        activeValidator.set(null);
        return true;
    }
538050
public boolean bind(ValidationObject validationObject)
    {
        if (m_boundObjects.containsKey(validationObject))
        {
            return false;
        }
        m_boundObjects.put(validationObject,validationObject);
        return true;
    }
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);
        }

    }
953877
private boolean validate(TextInputControl tf) {
        boolean res = tf.getText().trim().length() == 0;
        ObservableList<String> styleClass = tf.getStyleClass();
        if (res) {
            if (!styleClass.contains("error")) {
                tf.setStyle("-text-area-background: " + errorColor + ";");
                styleClass.add("error");
            }
        } else {
            // remove all occurrences:
            tf.setStyle("-text-area-background: " + defaultColor + ";");
            styleClass.removeAll(Collections.singleton("error"));
        }

        return res;
    }