github.com/storacha/go-ucanto@v0.7.2/core/schema/literal.go (about)

     1  package schema
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/storacha/go-ucanto/core/result/failure"
     7  )
     8  
     9  func Literal(expected string) Reader[string, string] {
    10  	return reader[string, string]{
    11  		readFunc: func(input string) (string, failure.Failure) {
    12  			if input != expected {
    13  				return "", NewSchemaError(fmt.Sprintf("expected literal %s instead got %s", expected, input))
    14  			}
    15  			return input, nil
    16  		},
    17  	}
    18  }