Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Engine support for constraint, required validation #154

Merged
merged 18 commits into from
Jul 12, 2024

Commits on Jul 12, 2024

  1. Initial engine/client API for constraint/required validation

    As discussed in #140
    
    Based on 4c38a22, with some refinements:
    
    - Each condition’s validity state is now represented by `valid: boolean`
    - Minor naming adjustments
    - Nailed down an initial pair of message constants for engine-fallback messages
    - Added a method to check whether a message is an engine-fallback, in a way that allows type narrowing and produces those message constants as types
    - Added a ton of JSDoc documentation clarifying the design, expected usage, some anticipated performance caveats, etc
    eyelidlessness committed Jul 12, 2024
    Configuration menu
    Copy the full SHA
    9ff8fda View commit details
    Browse the repository at this point in the history
  2. Expand text definitions to support constraintMsg, requiredMsg

    Note: as described in the included TODO.md, this begins moving some parsing logic into a dedicated directory. This is a direction I’d wanted to take for some time. It felt particularly appropriate now because parsing these aspects of text no longer fits in the current body directory (itself entirely concerned with parsing, but only implicitly so), and it felt particuarly awkward to introduce another parsing-related top-level source directory (moving further *away* from this intent rather than inching towards it). I’d like to consider moving the rest of parsing logic into this directory within the same PR. It will almost certainly be just moving files and updating imports from here (and then TODO.md will never need to appear).
    eyelidlessness committed Jul 12, 2024
    Configuration menu
    Copy the full SHA
    beb4d38 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    96a9921 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    e94c389 View commit details
    Browse the repository at this point in the history
  5. Initial constraint/required implementation (value nodes)

    Note: this is intentionally a naive first pass! It does not defer computation as extensively as it could. I believe it is worth having that possibility documented, but measuring real world performance before optimizing further.
    eyelidlessness committed Jul 12, 2024
    Configuration menu
    Copy the full SHA
    cf34554 View commit details
    Browse the repository at this point in the history
  6. Initial aggregated violations implementation (ancestor nodes)

    Note: this is also a naive first pass! Aggregated results are not stored in a client state object, but rather computed up from leaf nodes (where both engine/client state are read to ensure reactivity on both sides of that boundary).
    eyelidlessness committed Jul 12, 2024
    Configuration menu
    Copy the full SHA
    5cbfb62 View commit details
    Browse the repository at this point in the history
  7. Fix: special case casting of boolean expressions which evaluate to si…

    …ngle node node-set
    
    This affects some `scenario` validation tests. It will also fix a few other tests which currently fail because of this difference in XPath/XForms boolean semantics (details in JSDoc).
    eyelidlessness committed Jul 12, 2024
    Configuration menu
    Copy the full SHA
    ac20ff5 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    9b9efc5 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    a5f33b2 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    379b339 View commit details
    Browse the repository at this point in the history
  11. Add tests for validation messages

    - Form-specified constraintMsg, requiredMsg
    - Default/fallback messages for both conditions, as provided by the engine
    eyelidlessness committed Jul 12, 2024
    Configuration menu
    Copy the full SHA
    d583b9f View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    573b06b View commit details
    Browse the repository at this point in the history
  13. Fix (quick and dirty): client reactivity of parent node validation state

    In theory, we could do something like this to simplify children state logic as well, at least until we have a better general solution to storing/serializing/materializing complex nested state like direct references to node objects. I’d prefer to keep it isolated for now and think about priority of a more holistic solution.
    eyelidlessness committed Jul 12, 2024
    Configuration menu
    Copy the full SHA
    9a6fa61 View commit details
    Browse the repository at this point in the history
  14. Roll back boolean casting fix

    As we discussed, this can be handled in a separate scope of work. The original commits are left intact for reference, we can rebase before merge if preferred.
    eyelidlessness committed Jul 12, 2024
    Configuration menu
    Copy the full SHA
    d1acaa6 View commit details
    Browse the repository at this point in the history
  15. Remove node object from aggregated validation state

    Also eliminates most of the basis for the hacky custom client state solution, and so falls back to `createSharedNodeState`. This still isn’t ideal, as it’s redundantly storing a bunch of state that’s fundamentally derived. Worth considering whether the client interface should also accept an optional derived state factory (e.g. Vue’s `computed`, Solid’s `createMemo`).
    eyelidlessness committed Jul 12, 2024
    Configuration menu
    Copy the full SHA
    460f68a View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    23171c7 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    a385483 View commit details
    Browse the repository at this point in the history
  18. Fix (engine): skip validation of non-relevant nodes

    Note: no change to aggregation necessary! Derived state is awesome.
    eyelidlessness committed Jul 12, 2024
    Configuration menu
    Copy the full SHA
    200c222 View commit details
    Browse the repository at this point in the history