Text content validation
512510
def clean_text(self):
        
        text = self.cleaned_data.get("text")
        validation_helper = safe_import_module(settings.FORUM_TEXT_VALIDATOR_HELPER_PATH)
        if validation_helper is not None:
            return validation_helper(self, text)
        else:
            return text
83067
function text(txt) {
  if(!this.length) {
    return this;
  }
  if(txt === undefined) {
    return this.dom[0].textContent;
  }
  txt = txt || '';
  this.each(function(el) {
    el.textContent = txt;
  });
  return this;
}
88196
private void doText(Element received, Element source) {
        if (log.isDebugEnabled()) {
            log.debug("Validating node value for element: " + received.getLocalName());
        }

        String receivedText = DomUtils.getTextValue(received);
        String sourceText = DomUtils.getTextValue(source);

        if (receivedText != null) {
            Assert.isTrue(sourceText != null,
                    ValidationUtils.buildValueMismatchErrorMessage("Node value not equal for element '"
                            + received.getLocalName() + "'", null, receivedText.trim()));

            Assert.isTrue(receivedText.trim().equals(sourceText.trim()),
                    ValidationUtils.buildValueMismatchErrorMessage("Node value not equal for element '"
                            + received.getLocalName() + "'", sourceText.trim(),
                            receivedText.trim()));
        } else {
            Assert.isTrue(sourceText == null,
                    ValidationUtils.buildValueMismatchErrorMessage("Node value not equal for element '"
                            + received.getLocalName() + "'", sourceText.trim(), null));
        }

        if (log.isDebugEnabled()) {
            log.debug("Node value '" + receivedText.trim() + "': OK");
        }
    }
319003
protected void validateAttachmentContentId(SoapAttachment receivedAttachment, SoapAttachment controlAttachment) {
        //in case contentId was not set in test case, skip validation 
        if (!StringUtils.hasText(controlAttachment.getContentId())) { return; }
        
        if (receivedAttachment.getContentId() != null) {
            Assert.isTrue(controlAttachment.getContentId() != null, 
                    buildValidationErrorMessage("Values not equal for attachment contentId", 
                            null, receivedAttachment.getContentId()));

            Assert.isTrue(receivedAttachment.getContentId().equals(controlAttachment.getContentId()),
                    buildValidationErrorMessage("Values not equal for attachment contentId", 
                            controlAttachment.getContentId(), receivedAttachment.getContentId()));
        } else {
            Assert.isTrue(controlAttachment.getContentId() == null || controlAttachment.getContentId().length() == 0, 
                    buildValidationErrorMessage("Values not equal for attachment contentId", 
                            controlAttachment.getContentId(), null));
        }
        
        if (log.isDebugEnabled()) {
            log.debug("Validating attachment contentId: " + receivedAttachment.getContentId() + 
                    "='" + controlAttachment.getContentId() + "': OK.");
        }
    }
71694
function validateContentType(cb) {
        if (!_.isUndefined(kontx.args.meta) && !_.isUndefined(kontx.args.meta.type)) {
            db.contentTypes.getById(kontx.args.meta.type.toString()).then(
                function(contentType) {
                    cb(null, contentType);
                },
                function() {
                    cb(createError(400, messages.invalid_content_type));
                });
        } else {
            cb(createError(400, messages.invalid_content_type));
        }

    }
610257
private static void validateMessageText(String messageML) throws InvalidInputException {
    if (messageML == null) { throw new InvalidInputException("Message input is NULL"); }

    for (char ch : messageML.toCharArray()) {
      if (ch != '\n' && ch != '\r' && ch != '\t' && (ch < ' ')) {
        throw new InvalidInputException("Invalid control characters in message");
      }
    }
  }
833087
function validateFloatHTTPInput( $data, $contentObjectAttribute, $classAttribute )
    {
        $min = $classAttribute->attribute( self::MIN_FIELD );
        $max = $classAttribute->attribute( self::MAX_FIELD );
        $inputState = $classAttribute->attribute( self::INPUT_STATE_FIELD );
        switch( $inputState )
        {
            case self::NO_MIN_MAX_VALUE:
                $state = $this->FloatValidator->validate( $data );
                if ( $state === eZInputValidator::STATE_ACCEPTED )
                {
                    return eZInputValidator::STATE_ACCEPTED;
                }
                else
                {
                    $contentObjectAttribute->setValidationError(
                        ezpI18n::tr(
                            'kernel/classes/datatypes',
                            'The given input is not a floating point number.'
                        )
                    );
                }
                break;
            case self::HAS_MIN_VALUE:
                $this->FloatValidator->setRange( $min, false );
                $state = $this->FloatValidator->validate( $data );
                if ( $state === eZInputValidator::STATE_ACCEPTED )
                {
                    return eZInputValidator::STATE_ACCEPTED;
                }
                else
                {
                    $contentObjectAttribute->setValidationError(
                        ezpI18n::tr(
                            'kernel/classes/datatypes',
                            'The input must be greater than %1'
                        ),
                        $min
                    );
                }
                break;
            case self::HAS_MAX_VALUE:
                $this->FloatValidator->setRange( false, $max );
                $state = $this->FloatValidator->validate( $data );
                if ( $state === eZInputValidator::STATE_ACCEPTED )
                {
                    return eZInputValidator::STATE_ACCEPTED;
                }
                else
                {
                    $contentObjectAttribute->setValidationError(
                        ezpI18n::tr(
                            'kernel/classes/datatypes',
                            'The input must be less than %1'
                        ),
                        $max
                    );
                }
                break;
            case self::HAS_MIN_MAX_VALUE:
                $this->FloatValidator->setRange( $min, $max );
                $state = $this->FloatValidator->validate( $data );
                if ( $state === eZInputValidator::STATE_ACCEPTED )
                {
                    return eZInputValidator::STATE_ACCEPTED;
                }
                else
                {
                    $contentObjectAttribute->setValidationError(
                        ezpI18n::tr(
                            'kernel/classes/datatypes',
                            'The input is not in defined range %1 - %2'
                        ),
                        $min, $max
                    );
                }
                break;
        }
        return eZInputValidator::STATE_INVALID;
    }
165444
def validate(self, value):
        """"""
        if value is not None and not isinstance(value, str):
            raise ValidationError("field must be a string")

        super().validate(value)
668480
public void validateText(XMLValidator vld, boolean lastSegment)
        throws XMLStreamException
    {
        // Shared buffer? Let's just pass that
        if (mInputStart >= 0) {
            vld.validateText(mInputBuffer, mInputStart, mInputStart + mInputLen, lastSegment);
        } else {
            /* Otherwise, can either create a combine buffer, or construct
             * a String. While former could be more efficient, let's do latter
             * for now since current validator implementations work better
             * with Strings.
             */
            vld.validateText(contentsAsString(), lastSegment);
        }
    }
185077
def _validate_xtext(xtext):
    """"""

    non_printables = _non_printable_finder(xtext)
    if non_printables:
        xtext.defects.append(errors.NonPrintableDefect(non_printables))
    if utils._has_surrogates(xtext):
        xtext.defects.append(errors.UndecodableBytesDefect(
            "Non-ASCII characters found in header token"))
879272
def matches_content?(element)
      return true if @content.nil?

      case @content
      when String
        element.content == @content
      when Regexp
        element.content =~ @content
      end
    end
613444
function(element, content) {
    var nodeName = element.nodeName.toLowerCase(),
        type = element.hasAttribute('type') ? element.getAttribute('type') : null;

    if (nodeName === 'textarea') {
      return true;
    }
    if (nodeName === 'input' 
      && ['text', 'password', 'number', 'date'].indexOf(type) !== -1) {
      return true;
    }
    return false;
  }
1153423
function validateIncomingContentItem(desc, context) {
  var ret = {ok: true};
  if (!context.member) {
    return 'NO MEMBER';
  }
  if (!desc.uri || desc.uri.indexOf('http') !== 0) {
    return 'indexContentItem not http ' + desc.uri;
  }

  ret.state = context.state || desc.state;

  ret.title = context.title || desc.title;

  // extract and process content
  if (!ret.queued && ret.state !== utils.states.content.queued) {
    if (!desc.content) {
      return 'no content for ' + JSON.stringify(desc, null, 2);
    }

// extract recognizable content
    var extracted = extractContent(desc);
    ret.extracted = { title: extracted.title };
    if (!ret.extracted.title && !desc.title) {
      GLOBAL.debug('not indexable content-type', desc.uri);
      return 'not indexable';
    }
  }

  ret.user = GLOBAL.svc.auth.getUserByUsername(context.member);
  if (!ret.user) {
    console.log(context.member, GLOBAL.config.users);
    return 'User not found ' + context.member;
  }
  return ret;
}
516473
function (value) {
        var self = this, i;

        if (isDefined(value)) {
          i = self.length;
          while (i--) {
            if ("innerText" in self[i]) {
              self[i].innerText = value;
            } else {
              self[0].textContent = value;
            }
          }

          return self;
        }

        return self[0] ? (self[0].innerText || self[0].textContent) : '';
      }
1167740
static function matchText( &$text, $match_pre, $match_post )
    {
        $ret = null;
        if ( $match_pre !== '' )
        {
            $pos = strpos( $text, $match_pre );
            if ( $pos === false )
                return null;

            $ret = substr( $text, $pos + strlen( $match_pre ) );
            $text = substr( $text, 0, $pos );
        }
        if ( $match_post !== '' )
        {
            $pos = strpos( $ret, $match_post );
            if ( $pos === false )
                return null;

            $text .= substr( $ret, $pos + 1 );
            $ret = substr( $ret, 0, $pos );
        }
        return $ret;
    }
1016570
protected final boolean validateCaptcha(String text) {
        if (captchaSupport != null) {
            String id = Stapler.getCurrentRequest().getSession().getId();
            return captchaSupport.validateCaptcha(id, text);
        }

        // If no Captcha Support then bogus validation always returns true
        return true;
    }
360085
def validate_contents(file_contents):
    """"""
    for name, contents in file_contents.items():
        if os.path.splitext(name)[1] != '.ipynb':
            continue
        if not contents:
            return False
        try:
            json_object = json.loads(contents)
        except ValueError:
            return False
    return True