github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/types/to_string.go (about)

     1  package types
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/MontFerret/ferret/pkg/runtime/core"
     7  	"github.com/MontFerret/ferret/pkg/runtime/values"
     8  )
     9  
    10  // TO_STRING takes an input value of any type and convert it into a string value.
    11  // @param {Any} value - Input value of arbitrary type.
    12  // @return {String} - String representation of a given value.
    13  func ToString(_ context.Context, args ...core.Value) (core.Value, error) {
    14  	err := core.ValidateArgs(args, 1, 1)
    15  
    16  	if err != nil {
    17  		return values.None, err
    18  	}
    19  
    20  	return values.NewString(args[0].String()), nil
    21  }