@ -5,24 +5,25 @@ import "reflect"
// FieldLevel contains all the information and helper functions
// to validate a field
type FieldLevel interface {
// returns the top level struct, if any
// Top returns the top level struct, if any
Top ( ) reflect . Value
// returns the current fields parent struct, if any or
// Parent returns the current fields parent struct, if any or
// the comparison value if called 'VarWithValue'
Parent ( ) reflect . Value
// returns current field for validation
// Field returns current field for validation
Field ( ) reflect . Value
// returns the field's name with the tag
// FieldName returns the field's name with the tag
// name taking precedence over the fields actual name.
FieldName ( ) string
// returns the struct field's name
// StructFieldName returns the struct field's name
StructFieldName ( ) string
// returns param for validation against current field
// Param returns param for validation against current field
Param ( ) string
// GetTag returns the current validations tag name
@ -33,7 +34,7 @@ type FieldLevel interface {
// underlying value and it's kind.
ExtractType ( field reflect . Value ) ( value reflect . Value , kind reflect . Kind , nullable bool )
// traverses the parent struct to retrieve a specific field denoted by the provided namespace
// GetStructFieldOK traverses the parent struct to retrieve a specific field denoted by the provided namespace
// in the param and returns the field, field kind and whether is was successful in retrieving
// the field at all.
//
@ -49,7 +50,7 @@ type FieldLevel interface {
// Deprecated: Use GetStructFieldOKAdvanced2() instead which also return if the value is nullable.
GetStructFieldOKAdvanced ( val reflect . Value , namespace string ) ( reflect . Value , reflect . Kind , bool )
// traverses the parent struct to retrieve a specific field denoted by the provided namespace
// GetStructFieldOK2 traverses the parent struct to retrieve a specific field denoted by the provided namespace
// in the param and returns the field, field kind, if it's a nullable type and whether is was successful in retrieving
// the field at all.
//
@ -57,7 +58,7 @@ type FieldLevel interface {
// could not be retrieved because it didn't exist.
GetStructFieldOK2 ( ) ( reflect . Value , reflect . Kind , bool , bool )
// GetStructFieldOKAdvanced is the same as GetStructFieldOK except that it accepts the parent struct to start looking for
// GetStructFieldOKAdvanced2 is the same as GetStructFieldOK except that it accepts the parent struct to start looking for
// the field and namespace allowing more extensibility for validators.
GetStructFieldOKAdvanced2 ( val reflect . Value , namespace string ) ( reflect . Value , reflect . Kind , bool , bool )
}
@ -107,12 +108,12 @@ func (v *validate) GetStructFieldOKAdvanced(val reflect.Value, namespace string)
return current , kind , found
}
// GetStructFieldOK returns Param returns param for validation against current field
// GetStructFieldOK2 returns Param returns param for validation against current field
func ( v * validate ) GetStructFieldOK2 ( ) ( reflect . Value , reflect . Kind , bool , bool ) {
return v . getStructFieldOKInternal ( v . slflParent , v . ct . param )
}
// GetStructFieldOKAdvanced is the same as GetStructFieldOK except that it accepts the parent struct to start looking for
// GetStructFieldOKAdvanced2 is the same as GetStructFieldOK except that it accepts the parent struct to start looking for
// the field and namespace allowing more extensibility for validators.
func ( v * validate ) GetStructFieldOKAdvanced2 ( val reflect . Value , namespace string ) ( reflect . Value , reflect . Kind , bool , bool ) {
return v . getStructFieldOKInternal ( val , namespace )