(inter interface{}, v *StringPtrValidation)
| 94 | } |
| 95 | |
| 96 | func StringPtr(inter interface{}, v *StringPtrValidation) (*string, error) { |
| 97 | if inter == nil { |
| 98 | return ValidateStringPtrProvided(nil, v) |
| 99 | } |
| 100 | casted, castOk := inter.(string) |
| 101 | if !castOk { |
| 102 | if v.CastScalar { |
| 103 | if !cast.IsScalarType(inter) { |
| 104 | return nil, ErrorInvalidPrimitiveType(inter, PrimTypeString, PrimTypeInt, PrimTypeFloat, PrimTypeBool) |
| 105 | } |
| 106 | casted = s.ObjFlatNoQuotes(inter) |
| 107 | } else if v.CastNumeric { |
| 108 | if !cast.IsNumericType(inter) { |
| 109 | return nil, ErrorInvalidPrimitiveType(inter, PrimTypeString, PrimTypeInt, PrimTypeFloat) |
| 110 | } |
| 111 | casted = s.ObjFlatNoQuotes(inter) |
| 112 | } else if v.CastInt { |
| 113 | if !cast.IsIntType(inter) { |
| 114 | return nil, ErrorInvalidPrimitiveType(inter, PrimTypeString, PrimTypeInt) |
| 115 | } |
| 116 | casted = s.ObjFlatNoQuotes(inter) |
| 117 | } else { |
| 118 | return nil, ErrorInvalidPrimitiveType(inter, PrimTypeString) |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | return ValidateStringPtrProvided(&casted, v) |
| 123 | } |
| 124 | |
| 125 | func StringPtrFromInterfaceMap(key string, iMap map[string]interface{}, v *StringPtrValidation) (*string, error) { |
| 126 | inter, ok := ReadInterfaceMapValue(key, iMap) |
no test coverage detected