public static RopResult <String10, DomainMessage> CreateFirstName(string firstName)
        {
            var opt = String10.Create(firstName);

            return(Option.Match(
                       opt,
                       Rop.Succeed <String10, DomainMessage>,
                       () => Rop.Fail <String10, DomainMessage>(DomainMessage.FirstNameIsRequired())
                       ));
        }
Example #2
0
        /// <summary>
        /// Create a new customer from the parameters. If not valid, return null
        /// </summary>
        public static PersonalName Create(String10 first, String10 last)
        {
            if (first == null)
            {
                return(null);
            }
            if (last == null)
            {
                return(null);
            }

            // Compare this with the F# version, where the domain object
            // doesn't need to check for nulls

            return(new PersonalName(first, last));
        }
Example #3
0
 // No validation needed because types are already validated
 private PersonalName(String10 first, String10 last)
 {
     First = first;
     Last  = last;
 }