Title: lens, traverse and validate question · Issue #435 · functionaljava/functionaljava · GitHub
Open Graph Title: lens, traverse and validate question · Issue #435 · functionaljava/functionaljava
X Title: lens, traverse and validate question · Issue #435 · functionaljava/functionaljava
Description: I have deep hierarchal object that I need to validate. My question is how to accumulate and validate all validations in the data structure in one traversal? In the below example, suppose I want to vaildate OrderDocument and OrderItem in ...
Open Graph Description: I have deep hierarchal object that I need to validate. My question is how to accumulate and validate all validations in the data structure in one traversal? In the below example, suppose I want to ...
X Description: I have deep hierarchal object that I need to validate. My question is how to accumulate and validate all validations in the data structure in one traversal? In the below example, suppose I want to ...
Opengraph URL: https://github.com/functionaljava/functionaljava/issues/435
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"lens, traverse and validate question","articleBody":"I have deep hierarchal object that I need to validate. My question is how to accumulate and validate all validations in the data structure in one traversal?\r\n\r\nIn the below example, suppose I want to vaildate OrderDocument and OrderItem in one traversal, how to compose, traverse and add multiple validation in lens composition?\r\n\r\n```\r\n final Lens\u003cOrder, List\u003cOrderDocument\u003e\u003e orderDocumentsLens =\r\n Lens.lens(Order::getOrderDocuments, ds -\u003e cr -\u003e cr.withOrderDocuments(ds));\r\n final Lens\u003cOrderDocument, List\u003cOrderItem\u003e\u003e orderItemsLens =\r\n Lens.lens(OrderDocument::getOrderItems, is -\u003e crd -\u003e crd.withOrderItems(is));\r\n\r\n final Lens\u003cOrderItem, List\u003cOrderItemProperties\u003e\u003e orderItemPropertiesLens =\r\n Lens.lens(OrderItem::getOrderItemProperties, sls -\u003e i -\u003e i.withOrderItemProperties(sls));\r\n\r\n final List\u003cString\u003e fail = orderDocumentsLens.composeTraversal(List.Optic.traversal())\r\n .composeLens(orderItemsLens).composeTraversal(List.Optic.traversal())\r\n .composeLens(orderItemPropertiesLens).composeTraversal(List.Optic.traversal())\r\n .modifyValidationF(Semigroup.stringSemigroup, this::validateItemProperties)\r\n .f(order)\r\n .accumulate().fail();\r\n\r\n\r\n private Validation\u003cString, OrderItemProperties\u003e validateItemProperties(OrderItemProperties properties) {\r\n return Validation.success(properties);\r\n }\r\n\r\n```","author":{"url":"https://github.com/prabhu-madanagopal","@type":"Person","name":"prabhu-madanagopal"},"datePublished":"2022-02-02T01:49:02.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/435/functionaljava/issues/435"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a654d846-2520-aa69-9ba9-9c08a97f3d16 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B446:2B2A66:24C535:33DE53:6970A449 |
| html-safe-nonce | 4f00cfcf1e33eaa920032b5845c1715c292516d203d5f3eadefd803fc0043a32 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNDQ2OjJCMkE2NjoyNEM1MzU6MzNERTUzOjY5NzBBNDQ5IiwidmlzaXRvcl9pZCI6IjEwNDE2MjI0MDY3NjcwOTI4MDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 63acad30f5f9ac6e1d6e302b2651c6acb231bcfd0a6f950121ce45a503d49ad6 |
| hovercard-subject-tag | issue:1121421847 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/functionaljava/functionaljava/435/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bd1cfc6a6ebfcb97bd5b9004334ea01cf4680c6b68d2fd21001c318654508b0c/functionaljava/functionaljava/issues/435 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bd1cfc6a6ebfcb97bd5b9004334ea01cf4680c6b68d2fd21001c318654508b0c/functionaljava/functionaljava/issues/435 |
| og:image:alt | I have deep hierarchal object that I need to validate. My question is how to accumulate and validate all validations in the data structure in one traversal? In the below example, suppose I want to ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | prabhu-madanagopal |
| hostname | github.com |
| expected-hostname | github.com |
| None | b06a4c45c45fd0bb038b3759265ea6e38211f45d18130bc65261990be6b5972a |
| turbo-cache-control | no-preview |
| go-import | github.com/functionaljava/functionaljava git https://github.com/functionaljava/functionaljava.git |
| octolytics-dimension-user_id | 458836 |
| octolytics-dimension-user_login | functionaljava |
| octolytics-dimension-repository_id | 1033614 |
| octolytics-dimension-repository_nwo | functionaljava/functionaljava |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1033614 |
| octolytics-dimension-repository_network_root_nwo | functionaljava/functionaljava |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 0e1c4964831785bd64cb22d82e7cf2391ae01f45 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width