Skip to content
This repository was archived by the owner on Dec 18, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
31 changes: 26 additions & 5 deletions packages/common/validators/src/validators/is-rrn.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,37 @@ import { isRRN } from './is-rrn';
describe('isRRN', () => {
it('should return `false` if given value is not valid', () => {
expect(isRRN('19960729')).toEqual(false);
expect(isRRN('9607291111111')).toEqual(false);
expect(isRRN('')).toEqual(false);
// 마지막자리 검증공식 적용 테스트
expect(isRRN('9607291111111', { validate7thDigit: true })).toEqual(false);

// 외국인 등록번호 테스트
expect(isRRN('1111115111111')).toEqual(false); // 공식을 만족하는 외국인 등록번호
expect(isRRN('1111115111110', { allowForeigner: true })).toEqual(false); // 공식을 만족하지 않는 외국인 등록번호
expect(isRRN('1111115111111')).toEqual(false);
// 마지막자리 검증공식을 만족하지 않는 외국인 등록번호
expect(isRRN('1111115111110', { allowForeigner: true, validate7thDigit: true })).toEqual(false);
});
it('should return `true` if given value is valid', () => {
// 1911년 남성일 경우, 성별코드는 1
expect(isRRN('1111111012345')).toEqual(true);
// 1922년 여성일 경우, 성별코드는 2
expect(isRRN('2212222012345')).toEqual(true);
// 2011년 남성일 경우, 성별코드는 3
expect(isRRN('1111113012345')).toEqual(true);
// 2022년 여성일 경우, 성별코드는 4
expect(isRRN('2212224012345')).toEqual(true);

// 외국인 등록번호 1955년 남성일 경우, 성별코드는 5
expect(isRRN('5511115111111', { allowForeigner: true })).toEqual(true);
// 외국인 등록번호 1966년 여성일 경우, 성별코드는 6
expect(isRRN('6611116012345', { allowForeigner: true })).toEqual(true);
// 외국인 등록번호 2011년 남성일 경우, 성별코드는 7
expect(isRRN('1101017111111', { allowForeigner: true })).toEqual(true);
// 외국인 등록번호 2022년 여성일 경우, 성별코드는 8
expect(isRRN('2201018012345', { allowForeigner: true })).toEqual(true);

// 개인 주민번호로 테스트해보았을 때 잘 동작했음 (아래는 공식을 만족하는 임의의 주민등록번호)
expect(isRRN('1111111111118')).toEqual(true);
expect(isRRN('1111111111118', { validate7thDigit: true })).toEqual(true);
// 외국인 등록번호 테스트 (아래는 공식을 만족하는 임의의 외국인등록번호)
expect(isRRN('1111115111111', { allowForeigner: true })).toEqual(true);
expect(isRRN('1111115111111', { allowForeigner: true, validate7thDigit: true })).toEqual(true);
});
});
52 changes: 38 additions & 14 deletions packages/common/validators/src/validators/is-rrn.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
/** @tossdocs-ignore */
import { isBirthDate6 } from './is-birth-date-6';

export function isRRN(val: string, { allowForeigner }: { allowForeigner?: boolean } = { allowForeigner: false }) {
export function isRRN(
val: string,
{ allowForeigner, validate7thDigit }: { allowForeigner?: boolean; validate7thDigit?: boolean } = {
allowForeigner: false,
validate7thDigit: false,
}
) {
const len = val.length;
if (len !== 13) {
return false;
Expand All @@ -10,23 +15,42 @@ export function isRRN(val: string, { allowForeigner }: { allowForeigner?: boolea
return false;
}

let sum = 0;
for (let i = 0; i < len - 1; i = i + 1) {
const multiply = (i % 8) + 2;
const subResult = Number(val[i]) * multiply;
sum = sum + subResult;
if (validate7thDigit) {
let sum = 0;
for (let i = 0; i < len - 1; i = i + 1) {
const multiply = (i % 8) + 2;
const subResult = Number(val[i]) * multiply;
sum = sum + subResult;
}

let validateFactor = 11;

// allowForeigner = true인 경우 외국인 등록번호를 검증 factor를 설정한다.
const firstChar = val[6];
if (allowForeigner && (firstChar === '5' || firstChar === '6' || firstChar === '7' || firstChar === '8')) {
validateFactor = 13; // 외국인용 검증 factor
}

const expectedLastChar = (validateFactor - (sum % 11)) % 10;
return expectedLastChar === Number(val[len - 1]);
}

let validateFactor = 11;
const 주민번호성별코드 = val[6];

if (주민번호성별코드 == null) {
return false;
}

if (['1', '2', '3', '4'].includes(주민번호성별코드)) {
return true;
}

// allowForeigner = true인 경우 외국인 등록번호를 검증 factor를 설정한다.
const firstChar = val[6];
if (allowForeigner && (firstChar === '5' || firstChar === '6' || firstChar === '7' || firstChar === '8')) {
validateFactor = 13; // 외국인용 검증 factor
// allowForeigner = true인 경우 외국민 주민번호성별코드를 따른다.
if (allowForeigner && ['5', '6', '7', '8'].includes(주민번호성별코드)) {
return true;
}

const expectedLastChar = (validateFactor - (sum % 11)) % 10;
return expectedLastChar === Number(val[len - 1]);
return false;
}

export { isRRN as is주민등록번호 };
3 changes: 2 additions & 1 deletion packages/react/lottie/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"@toss/react": "workspace:^1.5.0",
"@toss/utils": "workspace:^1.4.4",
"lodash.debounce": "^4.0.8",
"lottie-web": "^5.5.9"
"lottie-web": "^5.5.9",
"suspend-react": "^0.1.3"
},
"devDependencies": {
"@babel/core": "^7",
Expand Down
1 change: 1 addition & 0 deletions packages/react/lottie/src/AnimationChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function AnimationChain(
animationInfos: AnimationData[],
options: {
container: HTMLElement;
shouldShowFirstFrameBeforeStart?: boolean;
loop?: LoopType;
interval?: number;
lottie: typeof lottie;
Expand Down
Loading