// UnmarshalText implements the encoding.TextUnmarshaler interface.
// Following formats are supported:
// "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
// "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}",
// "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8"
551245
func (u *UUID) UnmarshalText(text []byte) (err error) {
	if len(text) < 32 {
		err = fmt.Errorf("uuid: UUID string too short: %s", text)
		return
	}

	t := text[:]

	if bytes.Equal(t[:9], urnPrefix) {
		t = t[9:]
	} else if t[0] == '{' {
		t = t[1:]
	}

	b := u[:]

	for _, byteGroup := range byteGroups {
		if t[0] == '-' {
			t = t[1:]
		}

		if len(t) < byteGroup {
			err = fmt.Errorf("uuid: UUID string too short: %s", text)
			return
		}

		_, err = hex.Decode(b[:byteGroup/2], t[:byteGroup])

		if err != nil {
			return
		}

		t = t[byteGroup:]
		b = b[byteGroup/2:]
	}

	return
}
197879
func (z *Big) UnmarshalText(data []byte) error {
	return z.scan(bytes.NewReader(data))
}
869940
func (b *Board) UnmarshalText(text []byte) error {
	cp, err := fenBoard(string(text))
	if err != nil {
		return err
	}
	*b = *cp
	return nil
}
394615
func UnmarshalNext(dec *json.Decoder, pb proto.Message) error {
	return new(Unmarshaler).UnmarshalNext(dec, pb)
}
580501
func (ec *ErrorCode) UnmarshalText(text []byte) error {
	desc, ok := idToDescriptors[string(text)]

	if !ok {
		desc = ErrorCodeUnknown.Descriptor()
	}

	*ec = desc.Code

	return nil
}
852964
func UnmarshalText(s string, pb Message) error {
	if um, ok := pb.(textUnmarshaler); ok {
		err := um.UnmarshalText([]byte(s))
		return err
	}
	pb.Reset()
	v := reflect.ValueOf(pb)
	if pe := newTextParser(s).readStruct(v.Elem(), ""); pe != nil {
		return pe
	}
	return nil
}
918080
func (t *JSONTime) UnmarshalText(text []byte) error {
	if len(text) == 0 {
		*t = JSONTime{}
		return nil
	}
	time, err := time.Parse(time.RFC3339Nano, string(text))
	if err != nil {
		return err
	}
	*t = JSONTime(time)
	return nil
}
1140343
func (r *Recipient) UnmarshalText(text []byte) error {
	s := string(text)
	if s[len(s)-1:] != ">" {
		*r = Recipient{Email: s}
		return nil
	}

	i := strings.Index(s, "<")
	// at least 1 char followed by a space
	if i < 2 {
		return fmt.Errorf("malformed recipient string '%s'", s)
	}
	*r = Recipient{
		Name:  strings.TrimSpace(s[:i]),
		Email: s[i+1 : len(s)-1],
	}

	return nil
}
699955
func (n *BlockNonce) UnmarshalText(input []byte) error {
	return hexutil.UnmarshalFixedText("BlockNonce", input, n[:])
}
932052
func (t *Time) UnmarshalText(in []byte) error {
	parsed, err := time.Parse(time.RFC3339Nano, string(in))
	if err != nil {
		return err
	}
	t.Time = parsed
	return nil
}
64638
func (d *Duration) UnmarshalText(text []byte) error {
	if text == nil {
		*d = 0
		return nil
	}

	var (
		out  time.Duration
		sign time.Duration = 1
	)
	match := durationRegexp.FindStringSubmatch(string(text))
	if match == nil || strings.Join(match[2:6], "") == "" {
		return fmt.Errorf("invalid duration (%s)", text)
	}
	if match[1] == "-" {
		sign = -1
	}
	if match[2] != "" {
		y, err := strconv.Atoi(match[2])
		if err != nil {
			return fmt.Errorf("invalid duration years (%s): %s", text, err)
		}
		out += time.Duration(y) * year
	}
	if match[3] != "" {
		m, err := strconv.Atoi(match[3])
		if err != nil {
			return fmt.Errorf("invalid duration months (%s): %s", text, err)
		}
		out += time.Duration(m) * month
	}
	if match[4] != "" {
		d, err := strconv.Atoi(match[4])
		if err != nil {
			return fmt.Errorf("invalid duration days (%s): %s", text, err)
		}
		out += time.Duration(d) * day
	}
	if match[5] != "" {
		match := durationTimeRegexp.FindStringSubmatch(match[5])
		if match == nil {
			return fmt.Errorf("invalid duration (%s)", text)
		}
		if match[1] != "" {
			h, err := strconv.Atoi(match[1])
			if err != nil {
				return fmt.Errorf("invalid duration hours (%s): %s", text, err)
			}
			out += time.Duration(h) * time.Hour
		}
		if match[2] != "" {
			m, err := strconv.Atoi(match[2])
			if err != nil {
				return fmt.Errorf("invalid duration minutes (%s): %s", text, err)
			}
			out += time.Duration(m) * time.Minute
		}
		if match[3] != "" {
			s, err := strconv.ParseFloat(match[3], 64)
			if err != nil {
				return fmt.Errorf("invalid duration seconds (%s): %s", text, err)
			}
			out += time.Duration(s * float64(time.Second))
		}
	}

	*d = Duration(sign * out)
	return nil
}
1373719
func (d *Date) UnmarshalText(data []byte) (err error) {
	d.Time, err = time.Parse(fullDate, string(data))
	return err
}
759453
func (u *Unmarshaler) UnmarshalNext(dec *json.Decoder, pb proto.Message) error {
	inputValue := json.RawMessage{}
	if err := dec.Decode(&inputValue); err != nil {
		return err
	}
	if err := u.unmarshalValue(reflect.ValueOf(pb).Elem(), inputValue, nil); err != nil {
		return err
	}
	return checkRequiredFields(pb)
}
211176
func (co *ChangeOption) UnmarshalText(b []byte) error {
	s := strings.ToLower(strings.Trim(string(b), `"`))
	switch s {
	case strings.ToLower(string(RestartAllOnInstanceChanged)), strings.ToLower(string(RestartAllOnInstanceZeroDown)):
		*co = ChangeOption(s)
	case "":
		*co = DefaultChangeOption
	default:
		return errors.New("Invalid ChangeOption: " + s)
	}
	return nil
}
1103520
func (id *ID) UnmarshalText(text []byte) error {
	if len(text) != encodedLen {
		return ErrInvalidID
	}
	for _, c := range text {
		if dec[c] == 0xFF {
			return ErrInvalidID
		}
	}
	decode(id, text)
	return nil
}
750364
func (t *Token) UnmarshalText(data []byte) error {

	number := uint64(0)
	idx := 0.0
	chars := []byte(Base62)

	charsLength := float64(len(chars))
	tokenLength := float64(len(data))

	if tokenLength > MaxTokenLength {
		return ErrTokenTooBig
	} else if tokenLength < MinTokenLength {
		return ErrTokenTooSmall
	}

	for _, c := range data {
		power := tokenLength - (idx + 1)
		index := bytes.IndexByte(chars, c)
		if index < 0 {
			return ErrInvalidCharacter
		}
		number += uint64(index) * uint64(math.Pow(charsLength, power))
		idx++
	}

	// the token was successfully decoded
	*t = Token(number)
	return nil
}
170604
func (u *UUID) UnmarshalText(data []byte) error {
	if len(data) == 0 {
		return nil
	}
	id := Parse(string(data))
	if id == nil {
		return errors.New("invalid UUID")
	}
	*u = id
	return nil
}