mirror of
https://github.com/swc-project/swc.git
synced 2024-12-20 12:12:16 +03:00
df635c9e6d
swc_ecma_minifier: - Respect `inline_prevented`. - Mark the LHS of an assignment pattern property as a pattern. (https://github.com/vercel/next.js/issues/30498)
34 lines
865 B
JavaScript
34 lines
865 B
JavaScript
function string_create() {
|
|
return new StringSchema();
|
|
}
|
|
class StringSchema extends BaseSchema {
|
|
|
|
matches(regex, options) {
|
|
let excludeEmptyString = false;
|
|
let message;
|
|
let name;
|
|
|
|
if (options) {
|
|
if (typeof options === 'object') {
|
|
({
|
|
excludeEmptyString = false,
|
|
message,
|
|
name
|
|
} = options);
|
|
} else {
|
|
message = options;
|
|
}
|
|
}
|
|
|
|
return this.test({
|
|
name: name || 'matches',
|
|
message: message || string.matches,
|
|
params: {
|
|
regex
|
|
},
|
|
test: value => isAbsent(value) || value === '' && excludeEmptyString || value.search(regex) !== -1
|
|
});
|
|
}
|
|
|
|
}
|
|
string_create.prototype = StringSchema.prototype; |