UNPKG

robust-validator

Version:

Rule-based data validation library

1,493 lines (1,429 loc) 112 kB
'use strict'; var dateFns = require('date-fns'); const DEFAULT_OPTIONS = { stopOnFail: false, language: "en", dateFormat: "yyyy-MM-dd", }; let OPTIONS = { ...DEFAULT_OPTIONS, }; const getOptions = () => { return OPTIONS; }; const setOptions = async (value) => { OPTIONS = { ...OPTIONS, ...value, }; }; var isAccepted = (value) => { const acceptedValues = ["yes", "on", 1, "1", true]; return acceptedValues.includes(value); }; var isAfter = (value, date, extra) => { const inputValue = new Date(value); const comparisonDate = extra?.data[date] ? new Date(extra?.data[date]) : new Date(date); if (isNaN(inputValue.getTime()) || isNaN(comparisonDate.getTime())) { return false; } return inputValue > comparisonDate; }; var isAfterOrEqual = (value, date, extra) => { const inputValue = new Date(value); const comparisonDate = extra?.data[date] ? new Date(extra?.data[date]) : new Date(date); if (isNaN(inputValue.getTime()) || isNaN(comparisonDate.getTime())) { return false; } return inputValue >= comparisonDate; }; var isAlpha = (value) => { return /^[a-zA-Z]+$/.test(value); }; var isAlphaDash = (value) => { const regex = /^[a-zA-Z0-9-_]+$/; return regex.test(value); }; var isAlphaNum = (value) => { if (typeof value === "boolean") { return false; } return /^[a-zA-Z0-9]+$/.test(value); }; var isArray = (value) => { return Array.isArray(value); }; var isBefore = (value, date, extra) => { // Parse the date strings or use Date objects based on your needs const inputValue = new Date(value); const comparisonDate = extra?.data[date] ? new Date(extra?.data[date]) : new Date(date); if (isNaN(inputValue.getTime()) || isNaN(comparisonDate.getTime())) { return false; } // Compare the dates return inputValue < comparisonDate; }; var isBeforeOrEqual = (value, date, extra) => { // Parse the date strings or use Date objects based on your needs const inputValue = new Date(value); const comparisonDate = extra?.data[date] ? new Date(extra?.data[date]) : new Date(date); if (isNaN(inputValue.getTime()) || isNaN(comparisonDate.getTime())) { return false; } // Compare the dates return inputValue <= comparisonDate; }; var isBetween = (value, min, max, extra) => { // Convert min and max to numbers if they are not already const minValue = typeof min === "number" ? min : parseFloat(min); const maxValue = typeof max === "number" ? max : parseFloat(max); // If there is a numeric definition on the field, we should test the numeric // values of the data. const shouldBeNumeric = extra?.definition.split("|").includes("numeric") || false; if (shouldBeNumeric) { value = parseFloat(value); } // Check the size based on the type of value if (Array.isArray(value)) { return value.length >= minValue && value.length <= maxValue; } else if (typeof value === "string" && shouldBeNumeric === false) { return value.length >= minValue && value.length <= maxValue; } else if (typeof value === "number") { return value >= minValue && value <= maxValue; } // For other types, return false return false; }; var isBoolean = (value) => { // Check if the value is a boolean or a valid string representation of boolean if (typeof value === "boolean") { return true; } const lowerCaseValue = String(value).toLowerCase(); // Check for valid boolean string representations return ["true", "false", "0", "1"].includes(lowerCaseValue); }; const getValueViaPath = (data, path) => { const keys = path.split("."); let value = keys.reduce((acc, key) => { if (acc && typeof acc === "object" && key in acc) { return acc[key]; } return undefined; }, data); if (typeof value === "string") { value = value.trim(); } if (value === "") { return null; } return value; }; var isConfirmed = (value, context) => { const confirmedKey = `${context.field}_confirmed`; const confirmedValue = getValueViaPath(context.data, confirmedKey); return value === confirmedValue; }; var isDate = (value, dateFormat) => { const options = getOptions(); const format = dateFormat ?? options.dateFormat; const date = dateFns.parse(value, format, new Date()); return !isNaN(date); }; var isDigits = (value, length) => { if (typeof value === "boolean") { return false; } // Check if the value is numeric if (typeof value !== "number" && isNaN(Number(value))) { return false; } // Check if the length is numeric if (typeof length !== "number" && isNaN(Number(length))) { throw new Error(`Incorrect validation rule: digits:number`); } // Shouldn't be a float value if (Number(value) % 1 !== 0) { return false; } // Check if the length is exact return String(value).trim().length === Number(length); }; var isDigitsBetween = (value, min, max) => { if (value === null || value === undefined || typeof value === "boolean") { return false; } // Check if the value is numeric if (typeof value !== "number" && isNaN(Number(value))) { return false; } if (min === null || min === undefined || max === null || max === undefined) { throw new Error(`Incorrect validation rule: digits:min,max`); } if (typeof min !== "number" && isNaN(Number(min))) { // Check if the min is numeric throw new Error(`Incorrect validation rule: digits:min,max`); } // Check if the max is numeric if (typeof max !== "number" && isNaN(Number(max))) { throw new Error(`Incorrect validation rule: digits:min,max`); } // Shouldn't be a float value if (Number(value) % 1 !== 0) { return false; } // Check if the length is exact const length = String(value).trim().length; return length >= Number(min) && length <= Number(max); }; var isEmail = (value) => { return !!String(value) .toLowerCase() .match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|.(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/); }; var isHex = (value) => { return /^[0-9a-f]+$/i.test(String(value).trim()); }; var isIncludes = (value, ...args) => { let params; // validate() function passes the IContext all the time. So we should be sure // if there is an IContext parameter in the array. const maybeContext = args[args.length - 1]; if (typeof maybeContext === "object" && maybeContext.definition) { params = args.slice(0, -1); } else { params = args; } const options = params .map((item) => item.toString()) .map((item) => item.split(",")) .flat(); const items = options.map((item) => item.toString().trim().toLocaleLowerCase()); return items.includes((value || "").toString().trim().toLocaleLowerCase()); }; var isInteger = (value) => { if (isNaN(value)) { return false; } return String(parseInt(value, 10)) === String(value); }; var isMax = (value, size) => { if (value === null || value === undefined || typeof value === "boolean") { return false; } const check = Number(size); if (size === null || size === undefined || isNaN(check)) { throw new Error(`Incorrect validation rule: max:number`); } if (typeof value === "string") { return value.trim().length <= check; } const input = Number(value); if (isNaN(input)) { return false; } return input <= check; }; var isMin = (value, size) => { if (value === null || value === undefined || typeof value === "boolean") { return false; } const check = Number(size); if (size === null || size === undefined || isNaN(check)) { throw new Error(`Incorrect validation rule: max:number`); } if (typeof value === "string") { return value.trim().length >= check; } const input = Number(value); if (isNaN(input)) { return false; } return input >= size; }; var isNotIncludes = (value, ...args) => { if (value === undefined || value === null) { return true; } return !isIncludes(value, args); }; var isNumeric = (value) => { if (typeof value === "object") { return false; } if (String(value).trim().length === 0) { return true; } // Check if the string representation is numeric const stringValue = String(value).trim(); return stringValue !== "" && !isNaN(Number(stringValue)); }; var isRequired = (value) => { if (value === null || value === undefined) { return false; } if (Array.isArray(value)) { return true; } const content = String(value).trim(); return content.length > 0; }; var isSize = (value, size) => { if (value === null || value === undefined) { return false; } if (isNaN(Number(size))) { throw new Error(`Invalid validation rule: size:${size} (size:number)`); } if (typeof value === "string") { return String(value).trim().length === Number(size); } return value === Number(size); }; var isString = (value) => { return typeof value === "string"; }; var isUrl = (value) => { const urlRegex = /^(ftp|http|https):\/\/[^ "]+$/; return urlRegex.test(value); }; const RULE_FUNCTION_MAPS = { string: isString, boolean: isBoolean, accepted: isAccepted, after: isAfter, after_or_equal: isAfterOrEqual, alpha: isAlpha, alpha_dash: isAlphaDash, alpha_num: isAlphaNum, array: isArray, before: isBefore, before_or_equal: isBeforeOrEqual, between: isBetween, confirmed: isConfirmed, date: isDate, digits: isDigits, digits_between: isDigitsBetween, email: isEmail, hex: isHex, includes: isIncludes, integer: isInteger, max: isMax, min: isMin, not_includes: isNotIncludes, numeric: isNumeric, required: isRequired, size: isSize, url: isUrl, }; const TRANSLATIONS = {}; const setLocales = (values) => { if (Array.isArray(values)) { const locales = values; for (const item of locales) { mergeTranslations(item); } } else { const locale = values; mergeTranslations(locale); } }; const mergeTranslations = (locale) => { if (TRANSLATIONS[locale.key]) { TRANSLATIONS[locale.key] = { ...TRANSLATIONS[locale.key], ...locale.values, }; } else { TRANSLATIONS[locale.key] = locale.values; } }; const getLoadedLocales = () => { return Object.keys(TRANSLATIONS); }; const addCustomLocale = (locale, ruleName, translation) => { if (!TRANSLATIONS[locale]) { TRANSLATIONS[locale] = {}; } const root = TRANSLATIONS[locale]; if (root) { root[ruleName] = translation; } else { throw new Error(`The translation path couldn't find: ${locale}`); } }; const getMessage = (rule, params, language, customTranslations = {}) => { const defaultTranslations = TRANSLATIONS[language]; if (defaultTranslations === undefined) { throw new Error(`You should set locale: setLocales(["${language}"])`); } const translations = { ...defaultTranslations, ...customTranslations }; let message = translations[rule]; if (message === undefined) { throw new Error(`Undefined error message: ${rule} (${language})`); } for (const index in params) { message = message.replace(`{${index}}`, params[index]); } return message; }; const DEFINED_RULES = { ...RULE_FUNCTION_MAPS, }; const isRegistered = (name) => { return Object.keys(DEFINED_RULES).includes(name); }; const register = (name, ruleFunction, translations) => { if (DEFINED_RULES[name]) { throw new Error(`The rule name is already defined: ${name}`); } for (const locale of Object.keys(translations)) { const message = translations[locale]; if (message === undefined) { throw new Error(`The custom rule translation should be provided: ${locale}`); } addCustomLocale(locale, name, message); } DEFINED_RULES[name] = ruleFunction; }; const toRuleDefinition = (rule) => { const [name, paramsAsString] = rule.split(":"); const ruleType = toRuleType(name); const params = paramsAsString ? paramsAsString.split(",") : []; const callback = DEFINED_RULES[ruleType]; if (callback === undefined) { throw new Error(`Undefined validation rule: ${ruleType}`); } return { name: ruleType, callback, params, }; }; const toRuleType = (name) => { try { return name; } catch (error) { throw new Error(`Undefined rule: ${name}`); } }; const validate = async (data, definition, options) => { const currentOptions = { ...getOptions(), ...options, }; const { isValid, fields, results } = await getResults(data, definition, currentOptions); return { isValid, isInvalid: !isValid, fields, errors: results, }; }; const toTraverseArray = (data, definition) => { function resolvePath(data, path) { const parts = path.split("."); const result = []; function traverse(current, index = 0, resolvedPath = []) { if (index >= parts.length) { result.push({ path: resolvedPath.join("."), value: current }); return; } const part = parts[index]; if (part === "*") { if (Array.isArray(current)) { current.forEach((item, i) => { traverse(item, index + 1, [...resolvedPath, i]); }); } else if (current && typeof current === "object") { Object.keys(current).forEach((key) => { traverse(current[key], index + 1, [...resolvedPath, key]); }); } else { result.push({ path: [...resolvedPath, "*"].join("."), value: current, }); } } else { if (current && typeof current === "object" && part in current) { traverse(current[part], index + 1, [...resolvedPath, part]); } else { result.push({ path: [...resolvedPath, part].join("."), value: undefined, }); } } } traverse(data); return result; } const checks = []; // Example usage Object.entries(definition).forEach(([path, rules]) => { const resolved = resolvePath(data, path); checks.push({ path, rules, resolved }); }); return checks; }; const getResults = async (data, definition, options) => { let isValid = true; const fields = {}; const results = {}; const traverse = toTraverseArray(data, definition); for (const item of traverse) { const { path, rules, resolved } = item; fields[path] = true; const rulesAsString = Array.isArray(rules) ? rules.join("|") : rules; const ruleDefinitions = toRuleNameArray(rulesAsString).map(toRuleDefinition); const context = { data, field: path, definition: rulesAsString, }; for (const check of resolved) { // Checking all rules one by one for (const rule of ruleDefinitions) { // If the value is empty but the rule is not required, we don't execute // the rules if (rule.name !== "required" && (check.value === null || check.value === undefined)) { continue; } // Calling the rule function with the validation parameters const isRuleValid = await rule.callback(check.value, ...[...rule.params, context]); // Is the value valid? if (isRuleValid === false) { if (!results[check.path]) { results[check.path] = []; } isValid = false; fields[path] = false; // Setting the rule and the error message results[check.path].push({ rule: rule.name, message: getMessage(rule.name, rule.params, options.language, options.translations || {}), }); if (options.stopOnFail) { return { isValid: false, fields, results, }; } } } } } return { isValid, fields, results, }; }; const toRuleNameArray = (rules) => { if (Array.isArray(rules)) { return rules; } return rules.split("|"); }; /** * The field under validation must be yes, on, 1 or true. This is useful for * validating "Terms of Service" acceptance. * * @example * import { accepted } from "robust-validator" * * const definition = { * value: [accepted()] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#accepted */ var accepted = () => { return "accepted"; }; /** * The field under validation must be after the given date. * * @example * import { after } from "robust-validator" * * const definition = { * value: [after("2023-01-01")] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#after-date */ var after = (date) => { return `after:${date}`; }; /** * The field unter validation must be after or equal to the given field * * @example * import { afterOrEqual } from "robust-validator" * * const definition = { * value: [afterOrEqual("2023-01-01")] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#after-or-equal-date */ var afterOrEqual = (date) => { return `after_or_equal:${date}`; }; /** * The field under validation must be entirely alphabetic characters. * * @example * import { alpha } from "robust-validator" * * const definition = { * value: [alpha()] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#alpha */ var alpha = () => { return "alpha"; }; /** * The field under validation may have alpha-numeric characters, as well as * dashes and underscores. * * @example * import { alphaDash } from "robust-validator" * * const definition = { * value: [alphaDash()] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#alpha-dash */ var alphaDash = () => { return "alpha_dash"; }; /** * The field under validation must be entirely alpha-numeric characters. * * @example * import { alphaNum } from "robust-validator" * * const definition = { * value: [alphaNum()] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#alpha-num */ var alphaNum = () => { return "alpha_num"; }; /** * The field under validation must be an array. * * @example * import { array } from "robust-validator" * * const definition = { * value: [array()] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#array */ var array = () => { return "array"; }; /** * The field under validation must be before the given date. * * @example * import { before } from "robust-validator" * * const definition = { * value: [before("2023-01-01")] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#before-date */ var before = (date) => { return `before:${date}`; }; /** * The field under validation must be before or equal to the given date. * * @example * import { beforeOrEqual } from "robust-validator" * * const definition = { * value: [beforeOrEqual("2023-01-01")] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#before-or-equal-date */ var beforeOrEqual = (date) => { return `before_or_equal:${date}`; }; /** * The field under validation must have a size between the given min and max. * Strings, and numerics are evaluated in the same fashion as the size rule. * * @example * import { between } from "robust-validator" * * const definition = { * value: [between(5, 10)] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#between-min-max */ var between = (min, max) => { return `between:${min},${max}`; }; /** * The field under validation must be a boolean value of the form true, false, * 0, 1, 'true', 'false', '0', '1', * * @example * import { boolean } from "robust-validator" * * const definition = { * value: [boolean()] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#boolean */ var boolean = () => { return "boolean"; }; /** * The field under validation must have a matching field of foo_confirmed. * For example, if the field under validation is password, a matching * password_confirmed field must be present in the input. * * @example * import { confirmed } from "robust-validator" * * const definition = { * value: [confirmed()] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#confirmed */ var confirmed = () => { return "confirmed"; }; /** * The field under validation must be a valid date format. * * @example * import { date } from "robust-validator" * * const definition = { * value: [date("yyyy-MM-dd")] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#date-format */ var date = (dateFormat) => { if (dateFormat) { return `date|${dateFormat}`; } return "date"; }; /** * The field under validation must be numeric and must have an exact length of * value. * * @example * import { digits } from "robust-validator" * * const definition = { * value: [digits(4)] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#digits-value */ var digits = (length) => { return `digits:${length}`; }; /** * The field under validation must be numeric and must have length between * given min and max. * * @example * import { digitsBetween } from "robust-validator" * * const definition = { * value: [digitsBetween(4, 6)] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#digits-between-min-max */ var digitsBetween = (min, max) => { return `digits_between:${min},${max}`; }; /** * The field under validation must be formatted as an e-mail address. * * @example * import { email } from "robust-validator" * * const definition = { * value: [email()] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#email */ var email = () => { return "email"; }; /** * The field under validation should be a hexadecimal format. * * @example * import { hex } from "robust-validator" * * const definition = { * value: [hex()] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#hex */ var hex = () => { return "hex"; }; /** * Converts an array of strings into a comma-separated string prefixed with "includes:". * * @param {string[]} items - The array of strings to be joined. * @returns {string} The formatted string in the form "includes:item1,item2,...". */ var includes = (items) => { return `includes:${items.join(",")}`; }; /** * The field under validation must have an integer value. * * @example * import { integer } from "robust-validator" * * const definition = { * value: [integer()] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#integer */ var integer = () => { return "integer"; }; /** * Validate that an attribute is no greater than a given size * * @example * import { max } from "robust-validator" * * const definition = { * value: [max(20)] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#max-value */ var max = (value) => { return `max:${value}`; }; /** * Validate that an attribute is at least a given size. * * @example * import { min } from "robust-validator" * * const definition = { * value: [min(20)] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#min-value */ var min = (value) => { return `min:${value}`; }; /** * The field under validation must not be included in the given list of values. * * @example * import { notIncludes } from "robust-validator" * * const definition = { * value: [notIncludes(["apple", "orange"])] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#not-includes-foo-bar */ var notIncludes = (items) => { return `not_includes:${items.join(",")}`; }; /** * Validate that an attribute is numeric. The string representation of a number * will pass. * * @example * import { numeric } from "robust-validator" * * const definition = { * value: [numeric()] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#numeric */ var numeric = () => { return "numeric"; }; /** * The value should be defined. null, undefined or empty strings are not * acceptable. * * @example * import { required } from "robust-validator" * * const definition = { * value: [required()] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#required */ var required = () => { return "required"; }; /** * The field under validation must have a size matching the given value. * For string data, value corresponds to the number of characters. For numeric * data, value corresponds to a given integer value. * * @example * import { size } from "robust-validator" * * const definition = { * value: [size(10)] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#size-value */ var size = (value) => { return `size:${value}`; }; /** * The field under validation must be a string. * * @example * import { string } from "robust-validator" * * const definition = { * value: [string()] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#string */ var string = () => { return "string"; }; /** * Validate that an attribute has a valid URL format * * @example * import { url } from "robust-validator" * * const definition = { * value: [url()] * }; * @type {string} * @tutorial https://validator.axe-api.com/rules.html#url */ var url = () => { return "url"; }; const ar = { key: "ar", values: { accepted: "يجب قبول الحقل.", after: "يجب أن يكون الحقل بعد {0}.", after_or_equal: "يجب أن يكون الحقل مساويًا أو بعد {0}.", alpha: "يجب أن يحتوي الحقل على أحرف أبجدية فقط.", alpha_dash: "قد يحتوي الحقل على أحرف أبجدية وأرقام، وعلى الشرطات والشرطات السفلية فقط.", alpha_num: "يجب أن يكون الحقل أبجديًا رقميًا.", array: "يجب أن يكون الحقل مصفوفة.", before: "يجب أن يكون الحقل قبل {0}.", before_or_equal: "يجب أن يكون الحقل مساويًا أو قبل {0}.", between: "يجب أن يكون الحقل بين {0} و {1}.", boolean: "يجب أن يكون الحقل قيمة بولية.", confirmed: "تأكيد الحقل لا يتطابق.", email: "يجب أن يكون الحقل عنوان بريد إلكتروني.", date: "الحقل ليس بتنسيق تاريخ صالح.", digits: "يجب أن يحتوي الحقل على {0} أرقام.", digits_between: "يجب أن يكون الحقل بين {0} و {1} أرقام.", includes: "الحقل المحدد غير صالح.", integer: "يجب أن يكون الحقل عددًا صحيحًا.", hex: "يجب أن يكون الحقل بتنسيق سداسي عشر", min: "يجب أن يكون الحقل على الأقل {0}.", max: "قد لا يكون الحقل أكبر من {0}.", not_includes: "الحقل المحدد غير صالح.", numeric: "يجب أن يكون الحقل رقمًا.", required: "الحقل مطلوب.", size: "يجب أن يكون حجم الحقل {0}.", string: "يجب أن يكون الحقل نصًا.", url: "يجب أن يكون الحقل عنوان URL.", }, }; const az = { key: "az", values: { accepted: "Təsdiq olunmalıdır.", after: "Sahə {0}-dən sonra olmalıdır.", after_or_equal: "Sahə {0}-dən sonra və ya bərabər olmalıdır.", alpha: "Sahə yalnız hərflərdən ibarət olmalıdır.", alpha_dash: "Sahə yalnız hərf, rəqəm, tire və xətt simvollarından ibarət ola bilər.", alpha_num: "Sahə yalnız hərf və rəqəmlərdən ibarət olmalıdır.", array: "Sahə bir massiv olmalıdır.", before: "Sahə {0}-dən əvvəl olmalıdır.", before_or_equal: "Sahə {0}-dən əvvəl və ya bərabər olmalıdır.", between: "Sahə {0} və {1} arasında olmalıdır.", boolean: "Sahə bir boolean dəyər olmalıdır.", confirmed: "Sahə təsdiqi uyğun gəlmir.", email: "Sahə bir email olmalıdır.", date: "Sahə doğru bir tarix formatında deyil.", digits: "Sahə {0} rəqəmindən ibarət olmalıdır.", digits_between: "Sahə {0} və {1} arasında rəqəmlərdən ibarət olmalıdır.", includes: "Seçilmiş sahə yanlışdır.", integer: "Sahə bir tam ədəd olmalıdır.", hex: "Sahə doğru bir onalıq formatında olmalıdır", min: "Sahə ən az {0} olmalıdır.", max: "Sahə {0}-dən böyük olmamalıdır.", not_includes: "Seçilmiş sahə yanlışdır.", numeric: "Sahə bir rəqəm olmalıdır.", required: "Sahə tələb olunur.", size: "Sahənin ölçüsü {0} olmalıdır.", string: "Sahə bir simvol sırası olmalıdır.", url: "Sahə bir URL olmalıdır.", }, }; const be = { key: "be", values: { accepted: "Поле павінна быць прынята.", after: "Поле павінна быць пасля {0}.", after_or_equal: "Поле павінна быць роўнае ці пасля {0}.", alpha: "У полі могуць знаходзіцца толькі літары.", alpha_dash: "У полі могуць знаходзіцца толькі літары, лічбы, дэфісы і падкрэсленьні.", alpha_num: "Поле павінна ўтрымліваць толькі літары і лічбы.", array: "Поле павінна быць масівам.", before: "Поле павінна быць да {0}.", before_or_equal: "Поле павінна быць роўнае ці да {0}.", between: "Поле павінна быць паміж {0} і {1}.", boolean: "Поле павінна быць лагічным значэннем.", confirmed: "Пацвярджэнне поля не супадае.", email: "Поле павінна быць адрасам электроннай пошты.", date: "Поле не мае правільнага фармата даты.", digits: "Поле павінна складацца з {0} лічбаў.", digits_between: "Поле павінна быць паміж {0} і {1} лічбамі.", includes: "Выбранае поле несапраўднае.", integer: "Поле павінна быць цэлым лікам.", hex: "Поле павінна мець шаснаццатковы фармат", min: "Поле павінна быць не менш за {0}.", max: "Поле не можа быць больш за {0}.", not_includes: "Выбранае поле несапраўднае.", numeric: "Поле павінна быць лікам.", required: "Гэта поле абавязкова для запаўнення.", size: "Памер поля павінен быць {0}.", string: "Поле павінна быць радком.", url: "Поле павінна быць URL-адрасам.", }, }; const bg = { key: "bg", values: { accepted: "Полето трябва да бъде прието.", after: "Полето трябва да бъде след {0}.", after_or_equal: "Полето трябва да бъде равно или след {0}.", alpha: "Полето трябва да съдържа само буквени символи.", alpha_dash: "Полето може да съдържа само буквено-цифрови символи, както и тирета и долни черти.", alpha_num: "Полето трябва да бъде алфа-цифрово.", array: "Полето трябва да бъде масив.", before: "Полето трябва да бъде преди {0}.", before_or_equal: "Полето трябва да бъде равно или преди {0}.", between: "Полето трябва да бъде между {0} и {1}.", boolean: "Полето трябва да бъде булева стойност.", confirmed: "Полето за потвърждение не съвпада.", email: "Полето трябва да бъде имейл адрес.", date: "Полето не е валиден формат за дата.", digits: "Полето трябва да бъде {0} цифри.", digits_between: "Полето трябва да бъде между {0} и {1} цифри.", includes: "Избраното поле е невалидно.", integer: "Полето трябва да бъде цяло число.", hex: "Полето трябва да има шестнадесетичен формат", min: "Полето трябва да бъде поне {0}.", max: "Полето не може да бъде по-голямо от {0}.", not_includes: "Избраното поле е невалидно.", numeric: "Полето трябва да бъде число.", required: "Полето е задължително.", size: "Размерът на полето трябва да бъде {0}.", string: "Полето трябва да бъде низ.", url: "Полето трябва да бъде URL адрес.", }, }; const bs = { key: "bs", values: { accepted: "Polje mora biti prihvaćeno.", after: "Polje mora biti nakon {0}.", after_or_equal: "Polje mora biti jednako ili nakon {0}.", alpha: "Polje mora sadržavati samo alfabetske znakove.", alpha_dash: "Polje može sadržavati samo alfa-numeričke znakove, kao i crtice i donje crte.", alpha_num: "Polje mora biti alfanumeričko.", array: "Polje mora biti niz.", before: "Polje mora biti prije {0}.", before_or_equal: "Polje mora biti jednako ili prije {0}.", between: "Polje mora biti između {0} i {1}.", boolean: "Polje mora biti boolean vrijednost.", confirmed: "Potvrda polja se ne poklapa.", email: "Polje mora biti email adresa.", date: "Polje nije u validnom formatu datuma.", digits: "Polje mora imati {0} cifara.", digits_between: "Polje mora imati između {0} i {1} cifara.", includes: "Odabrano polje nije validno.", integer: "Polje mora biti cijeli broj.", hex: "Polje mora imati heksadecimalni format", min: "Polje mora biti barem {0}.", max: "Polje ne smije biti veće od {0}.", not_includes: "Odabrano polje nije validno.", numeric: "Polje mora biti broj.", required: "Polje je obavezno.", size: "Veličina polja mora biti {0}.", string: "Polje mora biti string.", url: "Polje mora biti URL adresa.", }, }; const ca = { key: "ca", values: { accepted: "El camp ha de ser acceptat.", after: "El camp ha de ser posterior a {0}.", after_or_equal: "El camp ha de ser igual o posterior a {0}.", alpha: "El camp ha de contenir només caràcters alfabètics.", alpha_dash: "El camp pot contenir només caràcters alfanumèrics, guions i guions baixos.", alpha_num: "El camp ha de ser alfanumèric.", array: "El camp ha de ser una matriu.", before: "El camp ha de ser anterior a {0}.", before_or_equal: "El camp ha de ser igual o anterior a {0}.", between: "El camp ha de ser entre {0} i {1}.", boolean: "El valor del camp ha de ser un booleà.", confirmed: "La confirmació del camp no coincideix.", email: "El camp ha de ser un correu electrònic.", date: "El camp no té un format de data vàlid.", digits: "El camp ha de tenir {0} dígits.", digits_between: "El camp ha de tenir entre {0} i {1} dígits.", includes: "El camp seleccionat no és vàlid.", integer: "El camp ha de ser un nombre enter.", hex: "El camp ha de tenir un format hexadecimal.", min: "El camp ha de ser com a mínim {0}.", max: "El camp no pot ser superior a {0}.", not_includes: "El camp seleccionat no és vàlid.", numeric: "El camp ha de ser un nombre.", required: "El camp és obligatori.", size: "La mida del camp ha de ser {0}.", string: "El camp ha de ser una cadena de text.", url: "El camp ha de ser una URL.", }, }; const cs = { key: "cs", values: { accepted: "Pole musí být přijato.", after: "Pole musí být po {0}.", after_or_equal: "Pole musí být rovno nebo po {0}.", alpha: "Pole musí obsahovat pouze abecední znaky.", alpha_dash: "Pole může obsahovat pouze alfanumerické znaky, stejně jako pomlčky a podtržítka.", alpha_num: "Pole musí být alfanumerické.", array: "Pole musí být pole.", before: "Pole musí být před {0}.", before_or_equal: "Pole musí být rovno nebo před {0}.", between: "Pole musí být mezi {0} a {1}.", boolean: "Pole musí být hodnota boolean.", confirmed: "Potvrzení pole neodpovídá.", email: "Pole musí být e-mail.", date: "Pole nemá platný formát data.", digits: "Pole musí mít {0} číslic.", digits_between: "Pole musí být mezi {0} a {1} číslicemi.", includes: "Vybrané pole je neplatné.", integer: "Pole musí být celé číslo.", hex: "Pole musí mít hexadecimální formát.", min: "Pole musí být alespoň {0}.", max: "Pole nesmí být větší než {0}.", not_includes: "Vybrané pole je neplatné.", numeric: "Pole musí být číslo.", required: "Pole je povinné.", size: "Velikost pole musí být {0}.", string: "Pole musí být řetězec.", url: "Pole musí být URL.", }, }; const cy = { key: "cy", values: { accepted: "Rhaid derbyn y maes.", after: "Rhaid i'r maes fod ar ôl {0}.", after_or_equal: "Rhaid i'r maes fod yn gyfartal neu ar ôl {0}.", alpha: "Rhaid i'r maes gynnwys dim ond nodau alffa.", alpha_dash: "Dim ond nodau alffa-ariannol a gromlinellau a thiriadau yn unig a all fod yn y maes.", alpha_num: "Rhaid i'r maes fod yn alffa-ariannol.", array: "Rhaid i'r maes fod yn array.", before: "Rhaid i'r maes fod cyn {0}.", before_or_equal: "Rhaid i'r maes fod yn gyfartal neu cyn {0}.", between: "Rhaid i'r maes fod rhwng {0} a {1}.", boolean: "Rhaid i'r maes fod yn werth boolean.", confirmed: "Nid yw'r cadarnhad maes yn cydweddu.", email: "Rhaid i'r maes fod yn e-bost.", date: "Nid yw'r maes yn fformat dyddiad dilys.", digits: "Rhaid i'r maes fod yn {0} digidau.", digits_between: "Rhaid i'r maes fod rhwng {0} a {1} digid.", includes: "Mae'r maes a ddewiswyd yn annilys.", integer: "Rhaid i'r maes fod yn gyfanrif.", hex: "Rhaid i'r maes fod â fformat hexadecanol", min: "Rhaid i'r maes fod o leiaf {0}.", max: "Nid yw'r maes yn gallu bod yn fwy na {0}.", not_includes: "Mae'r maes a ddewiswyd yn annilys.", numeric: "Rhaid i'r maes fod yn rif.", required: "Rhaid i'r maes fod yn ofynnol.", size: "Rhaid i faint y maes fod yn {0}.", string: "Rhaid i'r maes fod yn llinyn.", url: "Rhaid i'r maes fod yn URL.", }, }; const da = { key: "da", values: { accepted: "Feltet skal accepteres.", after: "Feltet skal være efter {0}.", after_or_equal: "Feltet skal være lig med eller efter {0}.", alpha: "Feltet skal kun indeholde alfabetiske karakterer.", alpha_dash: "Feltet må kun indeholde alfa-numeriske karakterer samt bindestreger og underscores.", alpha_num: "Feltet skal være alfanumerisk.", array: "Feltet skal være en liste.", before: "Feltet skal være før {0}.", before_or_equal: "Feltet skal være lig med eller før {0}.", between: "Feltet skal være mellem {0} og {1}.", boolean: "Feltet skal være en boolesk værdi.", confirmed: "Bekræftelsen af feltet matcher ikke.", email: "Feltet skal være en email.", date: "Feltet har ikke en gyldig datoformat.", digits: "Feltet skal være på {0} cifre.", digits_between: "Feltet skal være mellem {0} og {1} cifre.", includes: "Den valgte værdi er ugyldig.", integer: "Feltet skal være et heltal.", hex: "Feltet skal have en hexadecimal format", min: "Feltet skal være mindst {0}.", max: "Feltet må ikke være større end {0}.", not_includes: "Den valgte værdi er ugyldig.", numeric: "Feltet skal være et tal.", required: "Feltet er påkrævet.", size: "Feltets størrelse skal være {0}.", string: "Feltet skal være en streng.", url: "Feltet skal være en URL.", }, }; const de = { key: "de", values: { accepted: "Das Feld muss akzeptiert werden.", after: "Das Feld muss nach {0} liegen.", after_or_equal: "Das Feld muss gleich oder nach {0} liegen.", alpha: "Das Feld darf nur alphabetische Zeichen enthalten.", alpha_dash: "Das Feld darf nur alphanumerische Zeichen sowie Bindestriche und Unterstriche enthalten.", alpha_num: "Das Feld muss alphanumerisch sein.", array: "Das Feld muss ein Array sein.", before: "Das Feld muss vor {0} liegen.", before_or_equal: "Das Feld muss gleich oder vor {0} liegen.", between: "Das Feld muss zwischen {0} und {1} liegen.", boolean: "Das Feld muss einen booleschen Wert haben.", confirmed: "Die Bestätigung stimmt nicht überein.", email: "Das Feld muss eine E-Mail sein.", date: "Das Feld hat kein gültiges Datumsformat.", digits: "Das Feld muss {0} Ziffern haben.", digits_between: "Das Feld muss zwischen {0} und {1} Ziffern haben.", includes: "Die ausgewählte Option ist ungültig.", integer: "Das Feld muss eine ganze Zahl sein.", hex: "Das Feld sollte das Hexadezimalformat haben", min: "Das Feld muss mindestens {0} sein.", max: "Das Feld darf nicht größer als {0} sein.", not_includes: "Die ausgewählte Option ist ungültig.", numeric: "Das Feld muss eine Zahl sein.", required: "Das Feld ist erforderlich.", size: "Die Größe des Feldes muss {0} sein.", string: "Das Feld muss eine Zeichenkette sein.", url: "Das Feld muss eine URL sein.", }, }; const el = { key: "el", values: { accepted: "Το πεδίο πρέπει να γίνει αποδεκτό.", after: "Το πεδίο πρέπει να είναι μετά από {0}.", after_or_equal: "Το πεδίο πρέπει να είναι ίσο ή μετά από {0}.", alpha: "Το πεδίο πρέπει να περιέχει μόνο αλφαβητικούς χαρακτήρες.", alpha_dash: "Το πεδίο μπορεί να περιέχει μόνο αλφαριθμητικούς χαρακτήρες, καθώς και παύλες και κάτω παύλες.", alpha_num: "Το πεδίο πρέπει να είναι αλφαριθμητικό.", array: "Το πεδίο πρέπει να είναι πίνακας.", before: "Το πεδίο πρέπει να είναι πριν από {0}.", before_or_equal: "Το πεδίο πρέπει να είναι ίσο ή πριν από {0}.", between: "Το πεδίο πρέπει να είναι μεταξύ {0} και {1}.", boolean: "Το πεδίο πρέπει να είναι λογική τιμή.", confirmed: "Η επιβεβαίωση του πεδίου δεν ταιριάζει.", email: "Το πεδίο πρέπει να είναι έγκυρη διεύθυνση email.", date: "Το πεδίο δεν έχει έγκυρη μορφή ημερομηνίας.", digits: "Το πεδίο πρέπει να έχει {0} ψηφία.", digits_between: "Το πεδίο πρέπει να έχει ανάμεσα σε {0} και {1} ψηφία.", includes: "Το επιλεγμένο πεδίο δεν είναι έγκυρο.", integer: "Το πεδίο πρέπει να είναι ακέραιος αριθμός.", hex: "Το πεδίο πρέπει να έχει δεκαεξαδική μορφή", min: "Το πεδίο πρέπει να είναι τουλάχιστον {0}.", max: "Το πεδίο δεν πρέπει να είναι μεγαλύτερο από {0}.", not_includes: "Το επιλεγμένο πεδίο δεν είναι έγκυρο.", numeric: "Το πεδίο πρέπει να είναι αριθμός.", required: "Το πεδίο είναι υποχρεωτικό.", size: "Το μέγεθος του πεδίου πρέπει να είναι {0}.", string: "Το πεδίο πρέπει να είναι αλφαριθμητικό.", url: "Το πεδίο πρέπει να είναι URL.", }, }; const en = { key: "en", values: { accepted: "The field must be accepted.", after: "The field must be after {0}.", after_or_equal: "The field must be equal or after {0}.", alpha: "The field must contain only alphabetic characters.", alpha_dash: "The field may only contain alpha-numeric characters, as well as dashes and underscores.", alpha_num: "The field must be alphanumeric.", array: "The field must be an array.", before: "The field must be before {0}.", before_or_equal: "The field must be equal or before {0}.", between: "The field must be between {0} and {1}.", boolean: "The field must be a boolean value.", confirmed: "The field confirmation does not match.", email: "The field must be an email.", date: "The field is not a valid date format.", digits: "The field must be {0} digits.", digits_between: "The field must be between {0} and {1} digits.", includes: "The selected field is invalid.", integer: "The field must be an integer.", hex: "The field should have hexadecimal format", min: "The field must be at least {0}.", max: "The field may not be greater than {0}.", not_includes: "The selected field is invalid.", numeric: "The field must be a number.", required: "The field is required.", size: "The field's size must be {0}.", string: "The field must be a string.", url: "The field must be an URL.", }, }; const es = { key: "es", values: { accepted: "El campo debe ser aceptado.", after: "El campo debe ser después de {0}.", after_or_equal: "El campo debe ser igual o después de {0}.", alpha: "El campo debe contener solo caracteres alfabéticos.", alpha_dash: "El campo solo puede contener caracteres alfanuméricos, así como guiones y guiones bajos.", alpha_num: "El campo debe ser alfanumérico.", array: "El campo debe ser un array.", before: "El campo debe ser antes de {0}.", before_or_equal: "El campo debe ser igual o antes de {0}.", between: "El campo debe estar entre {0} y {1}.", boolean: "El campo debe ser un valor booleano.", confirmed: "La confirmación del campo no coincide.", email: "El campo debe ser un correo electrónico.", date: "El campo no tiene un formato de fecha válido.", digits: "El campo debe tener {0} dígitos.", digits_between: "El campo debe tener entre {0} y {1} dígitos.", includes: "El campo seleccionado no es válido.", integer: "El campo debe ser un número entero.", hex: "El campo debe tener formato hexadecimal", min: "El campo debe tener al menos {0}.", max: "El campo no puede ser mayor que {0}.", not_includes: "El campo seleccionado no es válido.", numeric: "El campo debe ser un número.", required: "El campo es obligatorio.", size: "El tamaño del campo debe ser {0}.", string: "El campo debe ser una cadena de texto.", url: "El campo debe ser una URL.", }, }; const et = { key: "et", values: { accepted: "Väli peab olema aktsepteeritud.", after: "Väli peab olema pärast {0}.", after_or_equal: "Väli peab olema võrdne või pärast {0}.", alpha: "Väli võib sisaldada ainult tähestikulisi märke.", alpha_dash: "Väli võib sisaldada ainult tähestikulisi ja numbrilisi märke, samuti kriipse ja allkriipse.", alpha_num: "Väli peab olema alfanumeeriline.", array: "Väli peab olema massiiv.", before: "Väli peab olema enne {0}.", before_or_equal: "Väli peab olema võrdne või enne {0}.", between: "Väli peab olema vahemikus {0} kuni {1}.", boolean: "Väli peab olema booleani väärtus.", confirmed: "Väli kinnitus ei kattu.", email: "Väli peab olema e-posti aadress.", date: "Väli ei ole kehtiv kuupäeva vorming.", digits: "Väli peab olema {0} numbrit.", digits_between: "Väli peab olema vahemikus {0} kuni {1} numbrit.", includes: "Valitud väli ei ole kehtiv.", integer: "Väli peab olema täisarv.", hex: "Väli peab olema heksadetsimaalne.", min: "Väli peab olema vähemalt {0}.", max: "Väli ei tohi olla suurem kui {0}.", not_includes: "Valitud väli ei ole kehtiv.", numeric: "Väli peab olema number.", required: "Väli on kohustuslik.", size: "Välja suurus peab olema {0}.", string: "Väli peab olema sõne.", url: "Väli peab olema URL.", }, }; const eu = { key: "eu", values: { accepted: "Kanpoko eremua onartu behar da.", after: "Eremua {0} ostean egon behar da.", after_or_equal: "Eremua {0} berdina edo ostean egon behar da.", alpha: "Eremuak alfabetako karaktereak izan behar ditu soilik.", alpha_dash: "Eremuak alfanumeriko karaktereak, marrak eta azpimarrak soilik izan ditzake.", alpha_num: "Eremuak alfanumerikoa izan behar da.", array: "Eremuak bilduma izan behar da.", before: "Eremua {0} aurretik egon behar da.", before_or_equal: "Eremua {0} berdina edo aurretik egon behar da.", between: "Eremua {0} eta {1} artean egon behar da.", boolean: "Eremua boolean balioa izan behar da.", confirmed: "Eremuaren baieztapena ez dator bat.", email: "Eremuak emaila izan behar du.", date: "Eremua ez da data formatu baliogarria.", digits: "Eremuak {0} digitu izan behar ditu.",