// Validate an input JSON string against the input schema (and return a set of errors
// or nil if the input JSON string matches the constraints defined in that schema)
545725
func ValidateSchema(schema, cfg string) []serror.SnapError {
	return cfgValidator.validateSchema(schema, cfg)
}
157414
func (constraints *tokenConstraints) validate() (err error) {
	keys := 0
	if constraints.key != nil {
		keys++
	}
	if constraints.secret != "" {
		keys++
	}
	if keys > 1 {
		err = fmt.Errorf("duplicate key constraints")
		return
	}
	if keys < 1 {
		err = fmt.Errorf("no key constraint")
		return
	}
	return
}
1180906
func ValidateKey(key string) error {
	if len(key) <= keyMaxLength && keyRegex.MatchString(key) {
		return nil
	}
	return fmt.Errorf("invalid key: %q", key)
}
467189
func (*IntSchema) Validate(v reflect.Value) bool {
	return reflect.TypeOf(dereference(v).Interface()).Kind() == reflect.Int32
}
318665
func (s *MapSchema) Validate(v reflect.Value) bool {
	v = dereference(v)

	return v.Kind() == reflect.Map && v.Type().Key().Kind() == reflect.String
}
140520
func (s *RecursiveSchema) Validate(v reflect.Value) bool {
	return s.Actual.Validate(v)
}
1187577
func (e Error) Validate(v interface{}) error {
	if e.Message == "" {
		return fmt.Errorf("invalid error message %q", e.Message)
	}

	if e.Code <= 0 {
		return fmt.Errorf("invalid error code %d", e.Code)
	}

	return nil
}
1082794
func (es Errors) Error() string {
	if len(es) == 0 {
		return ""
	}

	keys := []string{}
	for key := range es {
		keys = append(keys, key)
	}
	sort.Strings(keys)

	s := ""
	for i, key := range keys {
		if i > 0 {
			s += "; "
		}
		if errs, ok := es[key].(Errors); ok {
			s += fmt.Sprintf("%v: (%v)", key, errs)
		} else {
			s += fmt.Sprintf("%v: %v", key, es[key].Error())
		}
	}
	return s + "."
}
151271
func (o *Options) Validate() error {
	if o.Output != "" && o.Output != "yaml" && o.Output != "json" {
		return errors.New(`--output must be 'yaml' or 'json'`)
	}

	return nil
}
576110
func (s *Schema) Validate(queryString string) []*errors.QueryError {
	doc, qErr := query.Parse(queryString)
	if qErr != nil {
		return []*errors.QueryError{qErr}
	}

	return validation.Validate(s.schema, doc, s.maxDepth)
}
51907
func (v *ValidationError) Error() string {
	errString := "ValidationError: "
	for idx, err := range v.Errors {
		errString = fmt.Sprintf("%v\n   %v -  %v", errString, idx, err)
	}
	return errString
}
87078
func (s *UnionSchema) Validate(v reflect.Value) bool {
	v = dereference(v)
	for i := range s.Types {
		if t := s.Types[i]; t.Validate(v) {
			return true
		}
	}

	return false
}
431104
func ValidateString(input string) (bool, error) {
	_, err := time.ParseDuration(input)
	if err != nil {
		return false, err
	}

	return true, nil
}
684220
func ValidateString(s string) error {
	if s == "" {
		return errors.New("string is empty")
	}
	if strings.ContainsAny(s, ".$# \t\r\n") {
		return errors.New("string contains forbidden characters")
	}
	return nil
}
220534
func (m *ValidationError) UnmarshalJSON(raw []byte) error {
	// AO0
	var aO0 Error
	if err := swag.ReadJSON(raw, &aO0); err != nil {
		return err
	}
	m.Error = aO0

	// AO1
	var dataAO1 struct {
		Field string `json:"field,omitempty"`
	}
	if err := swag.ReadJSON(raw, &dataAO1); err != nil {
		return err
	}

	m.Field = dataAO1.Field

	return nil
}
137511
func (m *Error) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateCode(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateHelpURL(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateMessage(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
234986
func (self *MapTypeDef) Validate() error {
	if self.Type == "" {
		return fmt.Errorf("MapTypeDef.type is missing but is a required field")
	} else {
		val := Validate(RdlSchema(), "TypeRef", self.Type)
		if !val.Valid {
			return fmt.Errorf("MapTypeDef.type does not contain a valid TypeRef (%v)", val.Error)
		}
	}
	if self.Name == "" {
		return fmt.Errorf("MapTypeDef.name is missing but is a required field")
	} else {
		val := Validate(RdlSchema(), "TypeName", self.Name)
		if !val.Valid {
			return fmt.Errorf("MapTypeDef.name does not contain a valid TypeName (%v)", val.Error)
		}
	}
	if self.Keys == "" {
		return fmt.Errorf("MapTypeDef.keys is missing but is a required field")
	} else {
		val := Validate(RdlSchema(), "TypeRef", self.Keys)
		if !val.Valid {
			return fmt.Errorf("MapTypeDef.keys does not contain a valid TypeRef (%v)", val.Error)
		}
	}
	if self.Items == "" {
		return fmt.Errorf("MapTypeDef.items is missing but is a required field")
	} else {
		val := Validate(RdlSchema(), "TypeRef", self.Items)
		if !val.Valid {
			return fmt.Errorf("MapTypeDef.items does not contain a valid TypeRef (%v)", val.Error)
		}
	}
	return nil
}