chain_processor.go conditional_processor.go divider.go doc.go expression_validator.go joiner.go joiner_processor.go prefix_processor.go processor.go range_processor.go replacer_processor.go suffix_processor.go unis.go unis_test_.go validator.go
ClearProcessor returns a new string processor which always returns empty string back.
It can be used as a parameter to the library's functions.
IsMail returns a validator which returns true and a nil error if the receiver string is an e-mail.
Logger prints only errors that should "panic" (I don't like to call panic inside packages).
The user can assign this variable and change it in order to meet his project's meetings, Logger is just a func which accepts a string (func(string)).
To disable the logger assign the unis.Logger to a new logger.NewProd() from "/logger" package.
OriginProcessor returns a new string processor which always returns the "original" string back. It does nothing.
It can be used as a parameter to the library's functions.
Divide is an action which runs a new divider based on the "separator" and the "original" string.
Divider should be implemented by all string dividers.
DividerFunc is the alias type of Divider, it implements the Divider also.
NewDivider returns a new divider which splits a string into two pieces, based on the "separator".
On failure returns the original path as its first return value, and empty as it's second.
NewInvertOnFailureDivider accepts a Divider "divider" and returns a new one.
It calls the previous "divider" if succed then it returns the result as it is, otherwise it inverts the order of the result.
Rembmer: the "divider" by its nature, returns the original string and empty as second parameter if the divide action has being a failure.
Divide takes a string "original" and splits it into two pieces.
Joiner should be implemented by all string joiners.
JoinerFunc is the alias type of Joiner, it implements the Joiner also.
NewJoiner returns a new joiner which joins two strings into one string, based on a "jointer".
NewJoinerChain takes a Joiner and a chain of Processors and joins the Processors onto the output of the Joiner.
Join takes two pieces of strings and returns a result of them, as one.
Processor is the most important interface of this package.
It's being used to implement basic string processors. Users can use all these processors to build more on their packages.
A Processor should change the "original" and returns its result based on that.
ProcessorFunc same as Processor, as func. Implements the Processor.
If receives a "validator" Validator and two Processors, the first processor will be called when that validator passed, the second processor will be called when the validator failed. Both of the processors ("succeed" and "failure"), as always, can be results of .NewChain.
Returns a new string processor which checks the "validator" against the "original" string, if passed then it runs the "succeed", otherwise it runs the "failure".
Remember: it returns a ProcessorFunc, meaning that can be used in a new chain too.
NewAppender accepts a "suffix" and returns a new processor which returns the result appended with that "suffix".
NewChain returns a new chain of processors the result of the first goes to the second and so on.
NewConditional runs the 'p' processor, if the string didn't changed then it assumes that that processor has being a failure and it returns a Chain of the 'alternative' processor(s).
NewExclusivePrepender accepts a "prefix" and returns a new processor which returns the result prepended with that "prefix" if the "original"'s prefix != prefix. The difference from NewPrepender is that this processor will make sure that the prefix is that "prefix" series of characters, i.e: 1. "//path" -> NewPrepender("/") |> "//path"
It has a prefix already, so it doesn't prepends the "/" to the "//path", but it doesn't checks if that is the correct prefix.
1. "//path" -> NewExclusivePrepender("/") |> "/path"
Checks if that is the correct prefix, if so returns as it's, otherwise replace the duplications and prepend the correct prefix.
NewPrefixRemover accepts a "prefix" and returns a new processor which returns the result without that "prefix".
NewPrepender accepts a "prefix" and returns a new processor which returns the result prepended with that "prefix" if the "original"'s prefix != prefix.
NewRange accepts "begin" and "end" indexes. Returns a new processor which tries to return the "original[begin:end]".
NewRangeBegin almost same as NewRange but it accepts only a "begin" index, that means that it assumes that the "end" index is the last of the "original" string.
Returns the "original[begin:]".
NewRangeEnd almost same as NewRange but it accepts only an "end" index, that means that it assumes that the "start" index is 0 of the "original".
Returns the "original[0:end]".
NewReplacer accepts a map of old and new string values. The "old" will be replaced with the "new" one.
Same as for loop with a strings.Replace("original", old, new, -1).
NewSuffixRemover accepts a "suffix" and returns a new processor which returns the result without that "suffix".
NewTargetedJoiner accepts an "expectedIndex" as int and a "joinerChar" as byte and returns a new processor which returns the result concated with that "joinerChar" if the "original" string[expectedIndex] != joinerChar.
i.e: 1. "path", NewTargetedJoiner(0, '/') |> "/path" 2. "path/anything", NewTargetedJoiner(5, '*') |> "path/*anything".
Process accepts an "original" string and returns a result based on that.
Processors is a list of string Processor.
Validator is just another interface for string utilities. All validators should implement this interface. Contains only one function "Valid" which accepts a string and returns a boolean and an error. It should compare that string "str" with something and returns a true, nil or false, err.
Validators can be used side by side with Processors.
See .If for more.
ValidatorFunc is just an "alias" for the Validator interface. It implements the Validator.
NewMatcher returns a new validator which returns true and a nil error if the "expression" matches against a receiver string.
Valid accepts a string and returns a boolean and an error. It should compare that string "str" with something and returns a true, nil or false, err.