-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
6 changed files
with
198 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/*eslint-disable no-template-curly-in-string*/ | ||
|
||
import { printValue, LocaleObject } from 'yup'; | ||
|
||
// Based on https://github.com/jquense/yup/blob/b940eef48eb7456622ae384d0ffa7363d4fbad25/src/locale.ts | ||
export const mixed: LocaleObject['mixed'] = { | ||
default: '${path} je nevažeći.', | ||
required: '${path} je obavezno polje', | ||
defined: '${path} mora biti definisan', | ||
notNull: '${path} ne može biti null', | ||
oneOf: '${path} mora biti jedna od sljedećih vrijednosti: ${values}', | ||
notOneOf: '${path} ne smije biti jedna od sljedećih vrijednosti: ${values}', | ||
notType: ({ path, type, value, originalValue }) => { | ||
const isCast = originalValue != null && originalValue !== value; | ||
let msg = | ||
`${path} mora biti tipa \`${type}\`` + | ||
` ali konačna vrijednost bila je: \`${printValue(value, true)}\`` + | ||
(isCast | ||
? ` (pretvoreno iz vrijednosti \`${printValue(originalValue, true)}\`).` | ||
: '.'); | ||
|
||
if (value === null) { | ||
msg += | ||
`\nAko je "null" namijenjen kao prazna vrijednost, obavezno označite shemu kao` + | ||
' `.nullable()`'; | ||
} | ||
|
||
return msg; | ||
}, | ||
}; | ||
|
||
export const string: LocaleObject['string'] = { | ||
length: '${path} mora imati tačno ${length} karaktera', | ||
min: '${path} mora imati najmanje ${min} karaktera', | ||
max: '${path} mora imati najviše ${max} karaktera', | ||
matches: '${path} mora odgovarati sljedećem: "${regex}"', | ||
email: '${path} mora biti važeća email adresa', | ||
url: '${path} mora biti važeći URL', | ||
uuid: '${path} mora biti važeći UUID', | ||
trim: '${path} mora biti obrezan niz znakova', | ||
lowercase: '${path} mora biti niz znakova malim slovima', | ||
uppercase: '${path} mora biti niz znakova velikim slovima', | ||
}; | ||
|
||
export const number: LocaleObject['number'] = { | ||
min: '${path} mora biti veći ili jednak ${min}', | ||
max: '${path} mora biti manji ili jednak ${max}', | ||
lessThan: '${path} mora biti manje od ${less}', | ||
moreThan: '${path} mora biti veće od ${more}', | ||
positive: '${path} mora biti pozitivan broj', | ||
negative: '${path} mora biti negativan broj', | ||
integer: '${path} mora biti cijeli broj', | ||
}; | ||
|
||
export const date: LocaleObject['date'] = { | ||
min: '${path} polje mora biti kasnije od ${min}', | ||
max: '${path} polje mora biti ranije od ${max}', | ||
}; | ||
|
||
export const boolean: LocaleObject['boolean'] = { | ||
isValue: '${path} polje mora biti ${value}', | ||
}; | ||
|
||
export const object: LocaleObject['object'] = { | ||
noUnknown: | ||
'${path} polje ne smije imati ključeve koji nisu navedeni u obliku objekta', | ||
}; | ||
|
||
export const array: LocaleObject['array'] = { | ||
min: '${path} polje mora imati najmanje ${min} stavki', | ||
max: '${path} polje mora imati najviše ${max} stavki', | ||
length: '${path} mora imati ${length} stavki', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { printValue, LocaleObject } from 'yup'; | ||
|
||
export const mixed: LocaleObject['mixed'] = { | ||
default: '항목이 올바르지 않습니다.', | ||
required: '항목은 필수입니다.', | ||
defined: '항목 값이 정의되어야 합니다.', | ||
notNull: '항목은 null일수 없습니다.', | ||
oneOf: '항목은 다음 값중 하나여야 합니다: ${values}', | ||
notOneOf: '항목은 다음 값이 아니여야 합니다: ${values}', | ||
notType: ({ path, type, value, originalValue }) => { | ||
const castMsg = | ||
originalValue != null && originalValue !== value | ||
? ` (\`${printValue(originalValue, true)}\` 값에서 캐스팅).` | ||
: '.'; | ||
|
||
return type !== 'mixed' | ||
? `${path} 항목은 \`${type}\` 타입이 필요한데, ` + | ||
`최종 값은: \`${printValue(value, true)}\`` + | ||
castMsg | ||
: `${path} 항목은 구성된 타입과 일치해야 합니다. ` + | ||
`검증 값은: \`${printValue(value, true)}\`` + | ||
castMsg; | ||
}, | ||
}; | ||
|
||
export const string: LocaleObject['string'] = { | ||
length: '${path} 항목은 ${length} 글자여야 합니다.', | ||
min: '${path} 항목은 ${min} 글자이상이여야 합니다.', | ||
max: '${path} 항목은 ${max} 글자이하여야 합니다.', | ||
matches: '${path} 항목의 형식이 올바르지 않습니다: "${regex}"', | ||
email: '${path} 항목은 이메일형식이여야 합니다.', | ||
url: '${path} 항목은 URL형식이여야 합니다.', | ||
uuid: '${path} 항목은 UUID형식이여야 합니다.', | ||
trim: '${path} 항목은 압뒤공백이 없어야 합니다', | ||
lowercase: '${path} 항목은 소문자여야 합니다.', | ||
uppercase: '${path} 항목은 대문자여야 합니다.', | ||
}; | ||
|
||
export const number: LocaleObject['number'] = { | ||
min: '${path} 항목은 ${min} 이상이여야 합니다.', | ||
max: '${path} 항목은 ${max} 이하여야 합니다.', | ||
lessThan: '${path} 항목은 ${less} 미만이여야 합니다.', | ||
moreThan: '${path} 항목은 ${more} 초과여야 합니다.', | ||
positive: '${path} 항목은 양수여야 합니다.', | ||
negative: '${path} 항목은 음수여야 합니다.', | ||
integer: '${path} 항목은 정수여야 합니다.', | ||
}; | ||
|
||
export const date: LocaleObject['date'] = { | ||
min: '${path} 항목은 ${min} 이후여야 합니다.', | ||
max: '${path} 항목은 ${max} 이전이여야 합니다.', | ||
}; | ||
|
||
export const boolean: LocaleObject['boolean'] = { | ||
isValue: '${path} 항목은 ${value}여야 합니다.', | ||
}; | ||
|
||
export const object: LocaleObject['object'] = { | ||
noUnknown: '${path} 항목에 지정되지 않은 키가 있습니다: ${unknown}', | ||
}; | ||
|
||
export const array: LocaleObject['array'] = { | ||
min: '${path} 항목의 아이템은 ${min}개 이상이여야 합니다.', | ||
max: '${path} 항목의 아이템은 ${max}개 이하여야 합니다.', | ||
length: '${path} 항목의 아이템은 ${length}개여야 합니다.', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters