question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support customizing additional HAL-FORMS properties

See original GitHub issue

Now that we’ve got support for prompt thanks to #979, it would be nice to add support for the remaining “standard” HAL-Forms properties. I did notice that it adds the prompt everywhere using the name, rather than only adding it when defined. According to the spec, if the prompt is missing, clients MAY act as if it was set to the value of name. #979 kind of short-circuits that.

Some thoughts:

  • readOnly - could use absence of setter to auto-set
  • regex, required - #619 suggests using JSR-303, which seems like a clear and elegant solution
  • templated, value - honestly, I’m not certain at the moment what these would be used for, so I don’t feel qualified to make any suggestions

It seems easy enough to simply add the rest from a resource bundle, and I briefly considered creating a PR until I remembered the corporate proxy I’m stuck behind that blocks the git protocol, which, in this case, is probably a good thing since I think the solutions above are much more elegant and better for long-term maintenance of the consuming codebase. It might still be beneficial to allow overriding through resources, but I don’t know how that fits into the Spring philosophy (I’ve only just picked up Java again after a 15 year absence and Spring has changed just a little bit since then).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
odrotbohmcommented, Jul 18, 2019

The reason I made this distinction in the first place is that in domain types (as opposed to DTOs), JSR-303 is often used to “implement” domain constraints when a value type would’ve been the better alternative:

@Email
String emailAddress;

While this is perfectly fine in a DTO, it will probably have to be able to capture invalid values as well to produce proper validation messages, in the context of a domain object as nobody using the emailAddress property will be able to know whether it actually contains an email address or an arbitrary string. I.e. in a domain objects you’d definitely prepare:

EmailAddress emailAddress

I went ahead and added the support for JSR-303s @NotNull to mark required properties as well as @Pattern to define regular expressions. The later can also be used on types which will in turn render properties of those with the registered pattern. Also, HalFormsConfiguration now has a method to register patterns by type globally. See more on that in the updated reference documentation.

Please give the current snapshots a try. We still have one week until RC1 and I’m happy to tweak things further.

0reactions
colin-youngcommented, Aug 1, 2019

Looks good. Working as expected again.

One minor error in the docs: in Example 35 it shows Employee.firstName=Firstname but I think that should be Employee.firstName._prompt=Firstname. I created #1028 to fix it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The HAL-FORMS Media Type
Any library supporting the HAL-FORMS specification SHOULD support all of the core attributes and MAY support some or all of the additional attributes....
Read more >
Spring HATEOAS - Reference Documentation
Custom properties can be added via a Map or an explicit object (see below). To use a dedicated object for custom properties, declare...
Read more >
Manage form properties in Dynamics 365 Customer ...
You can access Form properties in solution explorer. Under Components, expand Entities, expand the entity you want, and then select Forms.
Read more >
4. HAL Clients - RESTful Web Clients [Book] - O'Reilly
HAL also supports passing state data in plain JSON properties or objects and ... custom HAL-FORMS extension, but that is not likely to...
Read more >
Spring HATEOAS Hal Forms does not add current GET ...
Perhaps it's part of the HAL-FORMS spec? 2. The templated property makes sense because your link has {?personId,bankingId} which means there are ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found