/// <summary>
        /// Add an additional validation step to the decoder.
        /// </summary>
        public static Decoder <TRaw, T2> ChainValidation <TRaw, T1, T2>(
            this Decoder <TRaw, T1> decoder,
            [NotNull] Func <T1, Either <string, T2> > f)
        {
            if (f == null)
            {
                throw new ArgumentNullException(nameof(f));
            }

            return(decoder.Bind(x =>
                                new Decoder <TRaw, T2>((id, data) =>
                                                       f(x).MapLeft(msg => DecoderErrors.Single(id, msg)))));
        }
示例#2
0
        /***********************************************/

        /* Methods
         * /***********************************************/

        /// <summary>
        /// Create a collection of DecoderErrors that contains the errors
        /// in this collection and the errors in b
        /// </summary>
        public DecoderErrors Append(DecoderErrors b)
        {
            return(new DecoderErrors(this.Errors.Concat(b.Errors)));
        }