// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT.

package test

import "encoding/json"
import "fmt"
import yaml "gopkg.in/yaml.v3"
import "regexp"

type Issue378 struct {
	// An escaped character that would otherwise be wrongly used
	Memory *string `json:"memory,omitempty,omitzero" yaml:"memory,omitempty" mapstructure:"memory,omitempty"`
}

// UnmarshalJSON implements json.Unmarshaler.
func (j *Issue378) UnmarshalJSON(value []byte) error {
	type Plain Issue378
	var plain Plain
	if err := json.Unmarshal(value, &plain); err != nil {
		return err
	}
	if plain.Memory != nil {
		if matched, _ := regexp.MatchString(`^\d+([tgmk]b)?$`, string(*plain.Memory)); !matched {
			return fmt.Errorf("field %s pattern match: must match %s", "Memory", `^\d+([tgmk]b)?$`)
		}
	}
	*j = Issue378(plain)
	return nil
}

// UnmarshalYAML implements yaml.Unmarshaler.
func (j *Issue378) UnmarshalYAML(value *yaml.Node) error {
	type Plain Issue378
	var plain Plain
	if err := value.Decode(&plain); err != nil {
		return err
	}
	if plain.Memory != nil {
		if matched, _ := regexp.MatchString(`^\d+([tgmk]b)?$`, string(*plain.Memory)); !matched {
			return fmt.Errorf("field %s pattern match: must match %s", "Memory", `^\d+([tgmk]b)?$`)
		}
	}
	*j = Issue378(plain)
	return nil
}
