1 line
5.5 KiB
JSON
1 line
5.5 KiB
JSON
{"ast":null,"code":"import { format } from \"../util\";\nvar range = function range(rule, value, source, errors, options) {\n var len = typeof rule.len === 'number';\n var min = typeof rule.min === 'number';\n var max = typeof rule.max === 'number';\n // 正则匹配码点范围从U+010000一直到U+10FFFF的文字(补充平面Supplementary Plane)\n var spRegexp = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/g;\n var val = value;\n var key = null;\n var num = typeof value === 'number';\n var str = typeof value === 'string';\n var arr = Array.isArray(value);\n if (num) {\n key = 'number';\n } else if (str) {\n key = 'string';\n } else if (arr) {\n key = 'array';\n }\n // if the value is not of a supported type for range validation\n // the validation rule rule should use the\n // type property to also test for a particular type\n if (!key) {\n return false;\n }\n if (arr) {\n val = value.length;\n }\n if (str) {\n // 处理码点大于U+010000的文字length属性不准确的bug,如\"𠮷𠮷𠮷\".length !== 3\n val = value.replace(spRegexp, '_').length;\n }\n if (len) {\n if (val !== rule.len) {\n errors.push(format(options.messages[key].len, rule.fullField, rule.len));\n }\n } else if (min && !max && val < rule.min) {\n errors.push(format(options.messages[key].min, rule.fullField, rule.min));\n } else if (max && !min && val > rule.max) {\n errors.push(format(options.messages[key].max, rule.fullField, rule.max));\n } else if (min && max && (val < rule.min || val > rule.max)) {\n errors.push(format(options.messages[key].range, rule.fullField, rule.min, rule.max));\n }\n};\nexport default range;","map":{"version":3,"names":["format","range","rule","value","source","errors","options","len","min","max","spRegexp","val","key","num","str","arr","Array","isArray","length","replace","push","messages","fullField"],"sources":["C:/Users/Аришина)/Desktop/promo/node_modules/@rc-component/async-validator/es/rule/range.js"],"sourcesContent":["import { format } from \"../util\";\nvar range = function range(rule, value, source, errors, options) {\n var len = typeof rule.len === 'number';\n var min = typeof rule.min === 'number';\n var max = typeof rule.max === 'number';\n // 正则匹配码点范围从U+010000一直到U+10FFFF的文字(补充平面Supplementary Plane)\n var spRegexp = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/g;\n var val = value;\n var key = null;\n var num = typeof value === 'number';\n var str = typeof value === 'string';\n var arr = Array.isArray(value);\n if (num) {\n key = 'number';\n } else if (str) {\n key = 'string';\n } else if (arr) {\n key = 'array';\n }\n // if the value is not of a supported type for range validation\n // the validation rule rule should use the\n // type property to also test for a particular type\n if (!key) {\n return false;\n }\n if (arr) {\n val = value.length;\n }\n if (str) {\n // 处理码点大于U+010000的文字length属性不准确的bug,如\"𠮷𠮷𠮷\".length !== 3\n val = value.replace(spRegexp, '_').length;\n }\n if (len) {\n if (val !== rule.len) {\n errors.push(format(options.messages[key].len, rule.fullField, rule.len));\n }\n } else if (min && !max && val < rule.min) {\n errors.push(format(options.messages[key].min, rule.fullField, rule.min));\n } else if (max && !min && val > rule.max) {\n errors.push(format(options.messages[key].max, rule.fullField, rule.max));\n } else if (min && max && (val < rule.min || val > rule.max)) {\n errors.push(format(options.messages[key].range, rule.fullField, rule.min, rule.max));\n }\n};\nexport default range;"],"mappings":"AAAA,SAASA,MAAM,QAAQ,SAAS;AAChC,IAAIC,KAAK,GAAG,SAASA,KAAKA,CAACC,IAAI,EAAEC,KAAK,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE;EAC/D,IAAIC,GAAG,GAAG,OAAOL,IAAI,CAACK,GAAG,KAAK,QAAQ;EACtC,IAAIC,GAAG,GAAG,OAAON,IAAI,CAACM,GAAG,KAAK,QAAQ;EACtC,IAAIC,GAAG,GAAG,OAAOP,IAAI,CAACO,GAAG,KAAK,QAAQ;EACtC;EACA,IAAIC,QAAQ,GAAG,iCAAiC;EAChD,IAAIC,GAAG,GAAGR,KAAK;EACf,IAAIS,GAAG,GAAG,IAAI;EACd,IAAIC,GAAG,GAAG,OAAOV,KAAK,KAAK,QAAQ;EACnC,IAAIW,GAAG,GAAG,OAAOX,KAAK,KAAK,QAAQ;EACnC,IAAIY,GAAG,GAAGC,KAAK,CAACC,OAAO,CAACd,KAAK,CAAC;EAC9B,IAAIU,GAAG,EAAE;IACPD,GAAG,GAA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