분류 전체보기 (644) 썸네일형 리스트형 [Spring] Validation(2) - Custom Validation Custom Validation의 두 가지 방법 1. AssertTrue / False 어노테이션을 통해 특정 메서드를 커스텀 검증 로직으로 적용 2. 커스텀 어노테이션 생성 및 ConstraintValidator를 적용하여 재사용 가능한 커스텀 검증 로직 적용 1) @AssertTrue 어노테이션을 이용한 검증 @Getter public class member { ... private String joinDate; @AssertTrue // 값이 true일 때 검증 성공 public boolean isValidDate() { if( ... ) { // joinDate의 값이 유효하지 않은 입력값일 때 return false; } return true; } } 클래스 내에 검증 로직을 적용한 메서드를 생.. [Spring] Validation(1) - Annotation Validation - Error나 Exception을 방지하기 위해서 미리 검증하는 과정 - 개발자가 주로 챙겨야 하는 검증은 크게 두 종류로 나뉜다. => 데이터 검증, 비즈니스 검증 데이터 검증 - 필수 데이터의 존재 유무 - 문자열의 길이나 숫자형 데이터의 경우 값의 범위 - email 등 특정 형식에 맞춘 데이터 비즈니스 검증 - 서비스의 정책에 따라 데이터를 확인하여 검증 - 경우에 따라 외부 API를 호출하거나 DB의 데이터까지 조회하여 검증하는 경우도 있다. 비즈니스 로직에 검증 코드 삽입 시 주의사항 1. 여러 가지 상황에 대해 검증 시 코드의 길이가 길어질 수 있다. 2. 핵심 로직과의 분리가 필요하다. 3. 검증 로직이 흩어져 있는 경우 혼란을 초래하고 재사용하기 어렵다. 스프링이 제.. [프로그래머스/자바] n보다 커질 때까지 더하기 class Solution { public int solution(int[] numbers, int n) { int answer = 0; for(int num : numbers) { answer += num; if(answer > n) break; } return answer; } } [프로그래머스/자바] 조건에 맞게 수열 변환하기 1 class Solution { public int[] solution(int[] arr) { for(int i=0; i= 50 && arr[i] % 2== 0) { arr[i] /= 2; } else if(arr[i] < 50 && arr[i] % 2 != 0) { arr[i] *= 2; } } return arr; } } [프로그래머스/자바] 수 조작하기 1 class Solution { public int solution(int n, String control) { char[] array = control.toCharArray(); for(char c : array) { if(c == 'w') n++; else if(c == 's') n--; else if(c == 'd') n += 10; else n -= 10; } return n; } } [프로그래머스/자바] n 번째 원소부터 import java.util.Arrays; class Solution { public int[] solution(int[] num_list, int n) { return Arrays.copyOfRange(num_list, n - 1, num_list.length); } } 49일차 - 페이스북 로그인, 인스타그램 연동하기 내 서비스에서 페이스북 로그인하기 https://developers.facebook.com/ Meta for Developers 꿈의 아틀리에 창조 BUCK의 크리에이터와 개발자로부터 Meta Spark를 사용하여 DIOR Beauty를 위한 AR 경험을 설계 및 빌드하는 과정에 대한 비하인드 스토리를 들어보세요. 이제 고급 액세스에 대한 비 developers.facebook.com 페이스북 아이디로 로그인 후 연결(?)하면 우측 상단에 '내 앱' 카테고리가 나타난다. 내 앱 > 앱 만들기 > 앱 유형 선택(소비자) > 앱 이름과 이메일 입력 후 '앱 만들기' 클릭 앱에 제품 추가 - Facebook 로그인 '설정' 버튼 클릭 > 좌측 메뉴의 Facebook 로그인 - 설정 > 유효한 OAuth 리다이.. [Java] throw Exception 테스트하기 실행 환경(build.gradle) dependencies { testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.2' testImplementation 'org.assertj:assertj-core:3.24.2' } spring-boot-starter-test가 있다면 바로 jUnit5를 사용할 수 있다. Exception을 throw하는 메서드 생성 public class MyArrayList implements List { ... public T get(int index) { if(index = size) {.. 이전 1 ··· 44 45 46 47 48 49 50 ··· 81 다음