1 /*
2  *  Make.org Core API
3  *  Copyright (C) 2020 Make.org
4  *
5  * This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU Affero General Public License as
7  *  published by the Free Software Foundation, either version 3 of the
8  *  License, or (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU Affero General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Affero General Public License
16  *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
17  *
18  */
19 
20 package org.make.api.user.validation
21 
22 import org.make.core.Validation.validateLegalConsent
23 import org.make.core.Requirement
24 
25 @deprecated("User profile requests are now automatically validated when parsed", since = "2023-09-19")
26 trait UserRequirement {
27   def requirement(request: UserProfileRequestValidation): Seq[Requirement]
28 }
29 
30 case object AgeIsRequired extends UserRequirement {
31   val value: String = "age-is-required"
32 
33   override def requirement(request: UserProfileRequestValidation): Seq[Requirement] = Seq.empty
34   // Seq(Validation.mandatoryField("dateOfBirth", request.dateOfBirth.birthDate))
35 }
36 
37 case object LegalConsent extends UserRequirement {
38   val value: String = "underage-legal-consent"
39 
40   override def requirement(request: UserProfileRequestValidation): Seq[Requirement] = {
41     Seq(
42       validateLegalConsent("legalMinorConsent", request.dateOfBirth.birthDate, request.legalMinorConsent),
43       validateLegalConsent("legalAdvisorApproval", request.dateOfBirth.birthDate, request.legalAdvisorApproval)
44     )
45   }
46 }
Line Stmt Id Pos Tree Symbol Tests Code
31 30112 1149 - 1166 Literal <nosymbol> org.make.api.user.validation.defaultuserregistrationvalidatortest "age-is-required"
33 29726 1254 - 1263 TypeApply scala.collection.SeqFactory.Delegate.empty org.make.api.user.validation.defaultuserregistrationvalidatortest scala.`package`.Seq.empty[Nothing]
38 28944 1422 - 1446 Literal <nosymbol> org.make.api.user.validation.defaultuserregistrationvalidatortest "underage-legal-consent"
41 29477 1540 - 1769 Apply scala.collection.SeqFactory.Delegate.apply org.make.api.user.validation.defaultuserregistrationvalidatortest scala.`package`.Seq.apply[org.make.core.Requirement](org.make.core.Validation.validateLegalConsent("legalMinorConsent", request.dateOfBirth.birthDate, request.legalMinorConsent, org.make.core.Validation.validateLegalConsent$default$4), org.make.core.Validation.validateLegalConsent("legalAdvisorApproval", request.dateOfBirth.birthDate, request.legalAdvisorApproval, org.make.core.Validation.validateLegalConsent$default$4))
42 30321 1551 - 1551 Select org.make.core.Validation.validateLegalConsent$default$4 org.make.api.user.validation.defaultuserregistrationvalidatortest org.make.core.Validation.validateLegalConsent$default$4
42 30201 1572 - 1591 Literal <nosymbol> org.make.api.user.validation.defaultuserregistrationvalidatortest "legalMinorConsent"
42 29635 1551 - 1650 Apply org.make.core.Validation.validateLegalConsent org.make.api.user.validation.defaultuserregistrationvalidatortest org.make.core.Validation.validateLegalConsent("legalMinorConsent", request.dateOfBirth.birthDate, request.legalMinorConsent, org.make.core.Validation.validateLegalConsent$default$4)
42 29497 1593 - 1622 Select org.make.core.Validation.BirthDate.birthDate org.make.api.user.validation.defaultuserregistrationvalidatortest request.dateOfBirth.birthDate
42 28973 1624 - 1649 Select org.make.api.user.validation.UserProfileRequestValidation.legalMinorConsent org.make.api.user.validation.defaultuserregistrationvalidatortest request.legalMinorConsent
43 28778 1679 - 1701 Literal <nosymbol> org.make.api.user.validation.defaultuserregistrationvalidatortest "legalAdvisorApproval"
43 30204 1658 - 1763 Apply org.make.core.Validation.validateLegalConsent org.make.api.user.validation.defaultuserregistrationvalidatortest org.make.core.Validation.validateLegalConsent("legalAdvisorApproval", request.dateOfBirth.birthDate, request.legalAdvisorApproval, org.make.core.Validation.validateLegalConsent$default$4)
43 28812 1658 - 1658 Select org.make.core.Validation.validateLegalConsent$default$4 org.make.api.user.validation.defaultuserregistrationvalidatortest org.make.core.Validation.validateLegalConsent$default$4
43 29679 1734 - 1762 Select org.make.api.user.validation.UserProfileRequestValidation.legalAdvisorApproval org.make.api.user.validation.defaultuserregistrationvalidatortest request.legalAdvisorApproval
43 30181 1703 - 1732 Select org.make.core.Validation.BirthDate.birthDate org.make.api.user.validation.defaultuserregistrationvalidatortest request.dateOfBirth.birthDate