我正在使用 SvelteKit 构建一个应用程序并将其发布到 Cloudflare Pages,但我使用的一些包无法访问节点本机函数。这是构建日志:
\n2022-07-30T19:05:14.200499Z > Using @sveltejs/adapter-cloudflare\n2022-07-30T19:05:14.227308Z \xe2\x9c\x98 [ERROR] Could not resolve "url"\n2022-07-30T19:05:14.227701Z \n2022-07-30T19:05:14.227859Z node_modules/sequelize/lib/sequelize.js:21:20:\n2022-07-30T19:05:14.228009Z 21 \xe2\x94\x82 const url = require("url");\n2022-07-30T19:05:14.22817Z \xe2\x95\xb5 ~~~~~\n2022-07-30T19:05:14.228388Z \n2022-07-30T19:05:14.228525Z The package "url" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.\n2022-07-30T19:05:14.228694Z \n2022-07-30T19:05:14.22885Z \xe2\x9c\x98 [ERROR] Could not resolve "path"\n2022-07-30T19:05:14.229004Z \n2022-07-30T19:05:14.229168Z node_modules/sequelize/lib/sequelize.js:22:21:\n2022-07-30T19:05:14.22932Z 22 \xe2\x94\x82 const path = require("path");\n2022-07-30T19:05:14.229452Z \xe2\x95\xb5 ~~~~~~\n2022-07-30T19:05:14.229593Z \n2022-07-30T19:05:14.229733Z The …Run Code Online (Sandbox Code Playgroud) 为什么ServiceStack没有在Validate方法中实现ruleSet可选参数?

例如,我有一个人员验证器
public class PersonValidator : AbstractValidator<Person> {
public PersonValidator() {
RuleSet("Names", () => {
RuleFor(x => x.Surname).NotNull();
RuleFor(x => x.Forename).NotNull();
});
RuleFor(x => x.Id).NotEqual(0);
}
}
Run Code Online (Sandbox Code Playgroud)
使用 ValidateAndThrow 调用验证器时如何指定规则集
通常这是在调用 ValidateAndThrow 时所做的
public class ActionClass
{
private readonly IValidator<Person> _validator;
public ActionClass(IValidator<Person> validator)
{
_validator=validator
}
public void ValidateForExample(Person model)
{
_validator.ValidateAndThrow(model)
//When there is no error I can continue with my operations
}
}
Run Code Online (Sandbox Code Playgroud)
我知道在校准验证时可以将规则集作为参数传递
我想知道是否也可以使用ValidateAndThrow来完成?