Decide on the Validation for Each Property in the Component
The type of data validation that you require for each property in a custom component determines whether you can use an existing standard property type or whether to create a custom one.
Usually when you create a custom Lightning web component, you include validations to verify that the data values that users enter into each component property are acceptable. In the Custom Article component example, these are the desired validations for the component's properties.
-
articleDate—You want to ensure that users enter a date. The standardlightning_dateTypeprovides the validation that you need, so you can use that standard Lightning type for this property. -
textAlignment—You don't need any data validations for this property, so you don't need a custom property type. You can just specify<property type="String">in thejs-meta.xmlfile for the Custom Article component. -
layoutProperties—You want to ensure that users always indicate a style, weight, and radius for the borders around the article. You can use the standard property type calledlightning__objectTypeto create a custom property type with multiple properties.
In this example, the desired validations require you to create one custom property type for layoutProperties. You can use standard property types for the other two custom properties.
See Also
- Lightning Types Developer Guide: Lightning Types Reference
- Decide on the Editor for Each Property in the Component
- Code samples: custom-property-editor-code-samples