// validateUNSUBACKBytes validates the fixed header and the variable header.
326296
func validateUNSUBACKBytes(fixedHeader FixedHeader, variableHeader []byte) error {
	// Extract the MQTT Control Packet type.
	ptype, err := fixedHeader.ptype()
	if err != nil {
		return err
	}

	// Check the length of the fixed header.
	if len(fixedHeader) != lenUNSUBACKFixedHeader {
		return ErrInvalidFixedHeaderLen
	}

	// Check the MQTT Control Packet type.
	if ptype != TypeUNSUBACK {
		return ErrInvalidPacketType
	}

	// Check the reserved bits of the fixed header.
	if fixedHeader[0]<<4 != 0x00 {
		return ErrInvalidFixedHeader
	}

	// Check the Remaining Length of the fixed header.
	if fixedHeader[1] != lenUNSUBACKVariableHeader {
		return ErrInvalidRemainingLength
	}

	// Check the length of the variable header.
	if len(variableHeader) != lenUNSUBACKVariableHeader {
		return ErrInvalidVariableHeaderLen
	}

	// Extract the Packet Identifier.
	packetID, _ := decodeUint16(variableHeader)

	// Check the Packet Identifier.
	if packetID == 0 {
		return ErrInvalidPacketID
	}

	return nil
}
843021
func restoreValidationErrors(req *Request) ([]*ValidationError, error) {
	var (
		err    error
		cookie ServerCookie
		errors = make([]*ValidationError, 0, 5)
	)
	if cookie, err = req.Cookie(CookiePrefix + "_ERRORS"); err == nil {
		ParseKeyValueCookie(cookie.GetValue(), func(key, val string) {
			errors = append(errors, &ValidationError{
				Key:     key,
				Message: val,
			})
		})
	}
	return errors, err
}
150354
func ValidateImageStreamUpdate(newStream, oldStream *imageapi.ImageStream) field.ErrorList {
	return ValidateImageStreamUpdateWithWhitelister(nil, newStream, oldStream)
}
1328532
func FromBytes(input []byte) (u UUID, err error) {
	err = u.UnmarshalBinary(input)
	return
}
485386
func (g *Gnostic) errorBytes(err error) []byte {
	return []byte("Errors reading " + g.sourceName + "\n" + err.Error())
}
1035074
func (s *Job) SetBackupSizeInBytes(v int64) *Job {
	s.BackupSizeInBytes = &v
	return s
}
569395
func byteSliceSubset(a, b []byte) bool {
	for i, el := range b {
		if el != a[i] {
			return false
		}
	}
	
	return true
}
1036046
func ValidateTags(tags []string) error {
	if len(tags) > maxTagCount {
		return fmt.Errorf("too many tags given (%d), expecting up to %d tags", len(tags), maxTagCount)
	}
	var merr errors.MultiError
	for i, tag := range tags {
		parts := strings.SplitN(tag, ":", 2) // ':' in values are allowed
		msg := ""
		switch {
		case len(parts) != 2:
			msg = "not in <key>:<value> form"
		case len(parts[0]) > maxTagKeySize:
			msg = fmt.Sprintf("the key length must not exceed %d", maxTagKeySize)
		case len(parts[1]) > maxTagValueSize:
			msg = fmt.Sprintf("the value length must not exceed %d", maxTagValueSize)
		}
		if msg != "" {
			merr = append(merr, fmt.Errorf("tag #%d: %s", i+1, msg))
		}
	}
	if len(merr) == 0 {
		return nil
	}
	return merr
}
1315498
func validateIngressBackend(backend *extensions.IngressBackend, fldPath *validation.FieldPath) validation.ErrorList {
	allErrs := validation.ErrorList{}

	// All backends must reference a single local service by name, and a single service port by name or number.
	if len(backend.ServiceName) == 0 {
		return append(allErrs, validation.NewRequiredError(fldPath.Child("serviceName")))
	} else if ok, errMsg := apivalidation.ValidateServiceName(backend.ServiceName, false); !ok {
		allErrs = append(allErrs, validation.NewInvalidError(fldPath.Child("serviceName"), backend.ServiceName, errMsg))
	}
	if backend.ServicePort.Type == intstr.String {
		if !validation.IsDNS1123Label(backend.ServicePort.StrVal) {
			allErrs = append(allErrs, validation.NewInvalidError(fldPath.Child("servicePort"), backend.ServicePort.StrVal, apivalidation.DNS1123LabelErrorMsg))
		}
		if !validation.IsValidPortName(backend.ServicePort.StrVal) {
			allErrs = append(allErrs, validation.NewInvalidError(fldPath.Child("servicePort"), backend.ServicePort.StrVal, apivalidation.PortNameErrorMsg))
		}
	} else if !validation.IsValidPortNum(backend.ServicePort.IntValue()) {
		allErrs = append(allErrs, validation.NewInvalidError(fldPath.Child("servicePort"), backend.ServicePort, apivalidation.PortRangeErrorMsg))
	}
	return allErrs
}
967295
func ValidateCode(ctx context.Context, b Backend, address common.Address) (bool, error) {
	code, err := b.CodeAt(ctx, address, nil)
	if err != nil {
		return false, err
	}
	return bytes.Equal(code, common.FromHex(contract.ContractDeployedCode)), nil
}
993655
func (s *BackupDetails) SetBackupSizeBytes(v int64) *BackupDetails {
	s.BackupSizeBytes = &v
	return s
}
1306005
func (b *BigIP) UploadBytes(data []byte, filename string) (*Upload, error) {
	r := bytes.NewReader(data)
	size := int64(len(data))
	return b.Upload(r, size, uriShared, uriFileTransfer, uriUploads, filename)
}
350627
func validateUnicodeEscape(escape, errMsg string) (interface{}, error) {
	r, _, _, err := strconv.UnquoteChar("\\"+escape, '"')
	if err != nil {
		return nil, errors.New(errMsg)
	}
	if 0xD800 <= r && r <= 0xDFFF {
		return nil, errors.New(errMsg)
	}
	return nil, nil
}
1022124
func (v *validator) checkUnsupported(cons Value) []string {
	return cons.hasAny(v.unsupported.Values()...)
}
395977
func (md *MobileDetect) CheckHttpHeadersForMobile() bool {
	for _, mobileHeader := range md.mobileHeaders() {
		if headerString, ok := md.httpHeaders[mobileHeader]; ok {
			mobileHeaderMatches := md.mobileHeaderMatches()
			if matches, ok := mobileHeaderMatches[mobileHeader]; ok {
				for _, match := range matches {
					if -1 != strings.Index(headerString, match) {
						return true
					}
				}
				return false
			} else {
				return true
			}
		}
	}
	return false
}
651590
func validateContentType(allowed []string, actual string) error {
	debugLog("validating content type for %q against [%s]", actual, strings.Join(allowed, ", "))
	if len(allowed) == 0 {
		return nil
	}
	mt, _, err := mime.ParseMediaType(actual)
	if err != nil {
		return errors.InvalidContentType(actual, allowed)
	}
	if swag.ContainsStringsCI(allowed, mt) {
		return nil
	}
	if swag.ContainsStringsCI(allowed, "*/*") {
		return nil
	}
	parts := strings.Split(actual, "/")
	if len(parts) == 2 && swag.ContainsStringsCI(allowed, parts[0]+"/*") {
		return nil
	}
	return errors.InvalidContentType(actual, allowed)
}
588812
func validatePINGRESPBytes(fixedHeader FixedHeader, remaining []byte) error {
	// Extract the MQTT Control Packet type.
	ptype, err := fixedHeader.ptype()
	if err != nil {
		return err
	}

	// Check the length of the fixed header.
	if len(fixedHeader) != lenPINGRESPFixedHeader {
		return ErrInvalidFixedHeaderLen
	}

	// Check the MQTT Control Packet type.
	if ptype != TypePINGRESP {
		return ErrInvalidPacketType
	}

	// Check the reserved bits of the fixed header.
	if fixedHeader[0]<<4 != 0x00 {
		return ErrInvalidFixedHeader
	}

	// Check the Remaining Length of the fixed header.
	if fixedHeader[1] != 0x00 {
		return ErrInvalidRemainingLength
	}

	// Check the length of the remaining.
	if len(remaining) != 0 {
		return ErrInvalidRemainingLen
	}

	return nil
}