public bool Validate()
        {
            ClearNotifications();

            if (NameValidations.FirstNameIsNotNull(Name))
            {
                AddNotifications("Name.FirstName", "O nome do pet não pode ser nulo");
            }

            if (NameValidations.LastNameIsNotNull(Name))
            {
                AddNotifications("Name.LastName", "O sobrenome do pet não pode ser nulo");
            }

            if (NameValidations.FirstIsLenghtOk(Name, 3, 20))
            {
                AddNotifications("Name.FirstName", "O nome do pet deve conter entre 3 e 20 caracteres");
            }

            if (NameValidations.LastIsLenghtOk(Name, 3, 20))
            {
                AddNotifications("Name.LastName", "O sobrenome do pet deve conter entre 3 e 20 caracteres");
            }

            if (string.IsNullOrEmpty(Breed))
            {
                AddNotifications("Breed", "A raça não pode estar em branco");
            }

            return((Notifications.Count == 0)? true:false);
        }
Esempio n. 2
0
        public bool Validate()
        {
            ClearNotifications();

            if (NameValidations.FirstNameIsNotNull(Name))
            {
                AddNotifications("Name.FirstName", "O nome não pode ser nulo");
            }


            if (NameValidations.LastNameIsNotNull(Name))
            {
                AddNotifications("Name.LastName", "O sobrenome não pode ser nulo");
            }


            if (NameValidations.FirstIsLenghtOk(Name, 3, 20))
            {
                AddNotifications("Name.FirstName", "O nome deve conter entre 3 e 20 caracteres");
            }

            if (NameValidations.LastIsLenghtOk(Name, 3, 20))
            {
                AddNotifications("Name.LastName", "O sobrenome deve conter entre 3 e 20 caracteres");
            }


            if (Document.DocumentType == EDocumentType.CPF)
            {
                if (!DocumentsValidations.IsCpf(Document.DocumentNumber))
                {
                    AddNotifications("Document.DocumentNumber", "O CPF é inválido");
                }
            }

            if (Document.DocumentType == EDocumentType.CNPJ)
            {
                if (!DocumentsValidations.IsCnpj(Document.DocumentNumber))
                {
                    AddNotifications("Document.DocumentNumber", "O CNPJ é inválido");
                }
            }



            return((Notifications.Count == 0)? true:false);
        }
Esempio n. 3
0
        public ValidationResult Validate()
        {
            var result = new NameValidations().Validate(this);

            return(result);
        }