首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Palantir车间给出的验证表参数

Palantir车间给出的验证表参数
EN

Stack Overflow用户
提问于 2022-08-06 19:32:10
回答 1查看 49关注 0票数 0

我们在Palantir车间中有一个表单,它获取值并将它们添加到本体对象中。我有一个任务来验证表单中给出的输入的组合(userId,startdate,state),不管它们是否已经存在。我们有类型记录函数,当我们提交那个表单时,它会被调用。我对打字稿完全陌生。你能帮我实现这个目标吗?

代码语言:javascript
复制
import {
    @OntologyEditFunction,
    LocalDate,
    Integer, 
    Users,
    Double,
    FunctionsMap, 
    Function,
} from "@foundry/functions-api";
import {
    Objects, 
    ObjectSet,
    ObjectWeUse,
} from "@foundry/ontology-api";
@OntologyEditFunction()
public async createSkus(
  userId: string,
  is_Sku_Pending?: string,
  partition?: string,
  startdate?: LocalDate,
  all_states?: string,
  states?: string[], //selects multiples values
): Promise<void> {
        let final_states;
        
        if (all_states && all_states === "All") {
            final_states = U.all_usa_states; // A pre defined const string array
        } else if (all_states && all_states === "All but UT") {
            final_states = U.all_usa_states_without_utah; // A pre defined const string array
        } else {
            final_states = states;
        }
for (let i = 0; i < packages.length; i++) {
            let sku= Objects.create().ObjectWeUse(U.uuidv4());
            sku.userId= U.uuidv4();
            sku.states= final_states;
            sku.strs = startdate;
            sku.partition = partition
            sku.isSkuPending = is_Sku_Pending;
EN

回答 1

Stack Overflow用户

发布于 2022-08-08 11:14:03

在铸造过程中,有两种确认行动的方法:

  1. 操作提交标准,它可用于所有操作类型,并允许您使用自定义用户反馈消息配置复杂的面向用户的提交验证。这是验证标准和向用户提供反馈的首选方法。在配置中,可以引用用户提供的任何输入参数以及对象参数的任何属性。这应该足够表达,以实现您希望进行的检查。
  2. 在函数支持的操作(实际上是任何函数)中,您可以抛出一个面向用户错误,这将阻止函数执行并向用户提供错误消息。这可以用于检查只有在函数执行时才能访问的条件,但这是更糟糕的用户体验,因为用户填写表单并单击按钮,然后才会收到错误消息。

我建议使用第一种方法。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73262737

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档