Skip to content

大佬,通过on使用场景验证时,会把contract_pdf字段也验证进去 #61

Open

Description

@Mr-GD

有解决办法吗,或者是我哪里使用错误了

Activity

  1. self-assigned this
    on May 24, 2023
  2. inhere commented on May 24, 2023

    @inhere
    Owner

    场景验证 on 和 scenarios 方式是二选一的。配置了 on 就不用配置 scenarios().

    doc: https://github.com/inhere/php-validate#%E5%9C%BA%E6%99%AF%E9%AA%8C%E8%AF%81

  3. Mr-GD commented on May 24, 2023

    @Mr-GD
    Author

    不能二者相结合吗?我想实现的是优先使用on的验证场景,但scenarios中也有声明该场景的情况下,也能使用rules中非on的规则验证。

  4. Mr-GD commented on May 24, 2023

    @Mr-GD
    Author

    在使用on绑定验证场景后,rules规则中后续的字段验证也都得加上on进行场景绑定,这样好像不太灵活。

  5. inhere commented on May 24, 2023

    @inhere
    Owner

    不加 on 就是通用的规则,每个场景都会使用。

  6. inhere commented on May 24, 2023

    @inhere
    Owner

    不能二者相结合吗?我想实现的是优先使用on的验证场景,但scenarios中也有声明该场景的情况下,也能使用rules中非on的规则验证。

    好像不行,优先用的 scenarios(), 配置了这个。rule 里面的可能就不会生效了。

  7. Mr-GD commented on May 26, 2023

    @Mr-GD
    Author

    在使用on绑定验证场景后,rules规则中后续的字段验证也都得加上on进行场景绑定,这样好像不太灵活。

    比如在某个场景中需要验证10个字段,里面有8个字段可以使用通过规则,只有两个字段需要特定处理,如果不能结合使用的话,相当于需要写10个on出来

  8. inhere commented on May 26, 2023

    @inhere
    Owner

    需要验证10个字段,里面有8个字段可以使用通过规则,只有两个字段需要特定处理 8个不写 on(不加on 就是通用规则), 2 个写 on 就可以了

  9. Mr-GD commented on May 27, 2023

    @Mr-GD
    Author

    如果这样的话,又回到我提出的这个问题了,在同一个验证器文件里面使用on和通用规则时,on验证完之后会接着往下验证一个通用的规则

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions