DEV Community

Cover image for Dynamic Attribute Sets and Field Validation in OneEntry
OneEntry
OneEntry

Posted on

Dynamic Attribute Sets and Field Validation in OneEntry

It’s a widely recognized fact among developers that building applications involves much more than simply managing standard entities such as products or pages. Today, businesses require dynamic and personalized solutions capable of rapid adaptation to constantly evolving market demands. For example, an online store might urgently need to set up new meta tags for SEO purposes, or swiftly adjust the attribute structure for product cards, including prices, images, SKUs, currencies, or booking time intervals.

This is exactly where dynamic attribute sets become essential. Attribute Sets allow you to easily expand and customize entities without the need for extensive technical work. Instead of rewriting data schemas or diving deep into the code, developers and content managers can visually manage application structures through an intuitive interface. This accelerates the development process and significantly reduces the likelihood of errors.

The OneEntry platform provides powerful tools for working with dynamic attributes and field validation, enabling teams to efficiently tackle tasks of any complexity. In this article, we’ll explore in detail how Attribute Sets and Validators in OneEntry simplify entity management and help effectively address key tasks: managing meta tags, images, pricing, SKUs, and other attributes, to enhance the flexibility and usability of your applications.

What Are Attribute Sets?

Attribute Sets in the OneEntry platform are tools designed to customize entities such as pages, products, or any other objects within your application. Using Attribute Sets, you can easily adapt content to your business requirements without constantly modifying code or database schemas.

Each attribute set consists of:

  • Name: A clear and understandable title displayed within the content management interface.
  • Marker: A unique identifier used to reference attributes programmatically or via the API.
  • Entity Type: Specifies the type of entity (e.g., pages, products, or other elements) the set will be associated with.

Creating a new attribute set in OneEntry is straightforward and intuitive. You simply specify the name, select the relevant entity type, and define a marker for quick and convenient data referencing in the future.

One of the key advantages of Attribute Sets is their ability to link directly with specific application entities. You can create multiple sets and selectively attach them to different types of entities. For example, a distinct set for products, another for pages, and yet another for events, enabling the system to automatically apply the relevant fields and attributes.

Creating an Attribute Set in OneEntry

Defining attributes and markers in OneEntry

Attribute Sets can also be hidden. This feature is particularly useful when you want to temporarily hide certain fields from editors or users without deleting them entirely. As a result, the interface remains clean and organized, providing administrators with convenient and practical management tools.

Attribute Set creation interface in OneEntry

Additionally, you can easily rearrange the order of attributes within a set. Simply dragging and dropping fields allows you to prioritize how content is displayed and entered, significantly simplifying daily tasks for both content managers and developers interacting with the system.

Reordering attributes within a set in OneEntry

Attributes: Types, Markers, Visibility

After creating an attribute set, the next step is populating it with attributes. In OneEntry, attributes are individual fields that allow you to input and manage diverse content within entities. Each attribute consists of:

  • Name: A clear and intuitive name shown within the interface to simplify content management.
  • Marker: A unique identifier allowing easy programmatic or API-based access to the attribute.
  • Type: Defines the data format determining what content the attribute will hold.

OneEntry offers a wide variety of attribute types to suit different content management scenarios:

  • String: Simple text fields, e.g., meta titles and descriptions for SEO optimization.
  • Image: Upload and manage images, including automatic size and file weight optimization, and placeholders if no image is uploaded.
  • List: Attributes with a predefined list of values, supporting multi-selection and adding images for each option. Perfect for selecting product colors or delivery options.
  • Float: Numeric fields for precise values, such as prices or item weights.
  • Entity: Links attributes to other entities within the system (e.g., associating a product with a specific page or category).
  • Time Interval: Configures time intervals, essential for bookings or event schedules.
  • JSON: Stores structured data in JSON format, convenient for transferring complex objects or configurations without creating additional fields.
  • Text: Multiline text fields ideal for detailed descriptions, instructions, or lengthy content.
  • Text with Header: Text fields with headers, useful for organizing long content and structured presentations.
  • Integer: Whole numbers, suitable for quantities, inventory stock, or order numbers.
  • Real Number: High-precision real numbers ideal for detailed specifications and precise calculations.
  • Floating Point Number: Numbers with decimal points, commonly used for prices, dimensions, and other detailed numerical data.
  • Date and Time: Fields for precise dates and times, suitable for publishing schedules, bookings, and event management.
  • Date: Specific dates, such as promotions or publication dates.
  • Time: Specific time fields, convenient for working hours or exact event timing.
  • File: Upload files of various formats, such as documents, archives, or PDFs, useful for content managers and end-users.
  • Group of Images: Ability to upload multiple images as a gallery or image set, ideal for products or events.
  • Switch: Simple on/off toggle for quickly changing status, such as activating or deactivating elements.
  • Spam Protection: Field designed to protect against spam, preventing automated form submissions and unwanted requests.
  • Button: Allows creating buttons with customizable actions, simplifying navigation or triggering specific commands within the application.

This wide array of attribute types ensures maximum flexibility and convenience in managing your application’s content effectively.

Practical Examples of Using Certain Attributes:

  • String: Attributes like "Meta Title" and "Description" are essential for managing page SEO data. Using string-type attributes, you can easily define unique and custom titles and descriptions for each page of your site.

  • Image: This attribute allows uploading and storing images. It includes an automatic optimization feature that reduces image file size without quality loss, ensuring fast page loading times and efficient resource usage.

  • List with Images: Enables selecting from multiple predefined options, each with an accompanying image (for example, product colors). You can easily reorder options, mark the field as required, and enable multiple selections.

Each attribute can also have additional fields added to it, such as placeholders or metadata, to enhance user experience during content entry. Attributes can also be hidden if you temporarily want to remove them from the user’s view while preserving their data and structure within the system. This feature ensures a clean and organized content management interface, improving usability and workflow efficiency.

Example of String attributes for SEO management in OneEntry

Configuring image attributes with optimization and placeholders in OneEntry

Preview Templates

Visual appeal and consistency in how content is displayed significantly impact user perception. OneEntry makes it easy to control how images appear within your application’s interface using Preview Templates.

A Preview Template is a predefined set of parameters used to automatically generate thumbnails from uploaded images. Setting up a Preview Template is straightforward and involves a few simple steps:

  • Image Dimensions: You can specify exact width and height values for vertical, horizontal, or square thumbnails. This ensures uniformity for all images throughout your site or application.

  • Alignment and Cropping: If uploaded images do not match the specified dimensions, the system automatically crops and aligns them according to your settings (e.g., centered or aligned to the top). This simplifies image processing and ensures a clean, professional visual style.

  • Markers: Each Preview Template has a unique marker, allowing you to reference it easily via code or APIs for subsequent use within your application.

Once created, a Preview Template can be effortlessly associated with an Image attribute in the OneEntry interface. For example, you might create a separate template for a product catalog, specifying clear dimensions and alignment settings. As products’ images are uploaded, these parameters automatically apply, freeing you from manually adjusting images and ensuring consistent visuals throughout all content.

This approach not only saves time but significantly improves the visual quality and consistency of your content, making your application neat, professional, and user-friendly.

Attribute Validation

Attribute validation ensures that users enter only accurate and expected data, reducing errors and simplifying content management. This significantly enhances user experience and saves valuable time that would otherwise be spent correcting mistakes.

With validation rules, you can easily set strict criteria to ensure data compliance with specified requirements. Let’s examine several practical examples:

  • Image Size and Format:

You can set restrictions so that uploaded images must be between 100KB and 2MB. Additionally, you can specify allowed file formats, for example, exclusively PNG. This prevents uploading excessively large or unsupported files, ensuring optimal app performance.

  • Required Fields:

Fields like “price” or “currency” can be set as mandatory. For example, the “price” field should be a float type to accommodate decimal values, while the “currency” field can be a string type restricted to specific options (such as only “$” or “€”). This ensures that essential data is consistently present and accurate.

  • Regular Expressions (Masks):

For attributes like SKU, you can establish strict validation rules using regular expressions. For example, enforcing a format such as "two uppercase letters followed by five digits" (e.g., AA12345). This significantly reduces input errors and simplifies workflow for both managers and developers.

  • Numeric Data and Lists:

Fields like "Quantity" are validated to ensure integer input, preventing accidental entry of incorrect values. Multi-select lists limit the user’s choices to predefined options and can be set as required fields if necessary.

Special attention should be given to Markers, allowing you to create customized hints and error messages directly within the user interface. If default system warnings are insufficient, Markers enable you to set personalized and informative messages explaining field requirements, further enhancing user-friendliness and reducing input errors.

Built-in validation rules in OneEntry substantially improve content quality and consistency, minimize errors, and ensure data reliability throughout the entire application lifecycle.

Additional Fields (Metadata)

Additional fields are static metadata that can be attached to attributes to enhance content entry and prevent mistakes. Such fields typically include placeholders, tooltips, and extra resources designed to guide users through form-filling processes more intuitively.

For example, an image attribute can include a placeholder—a pre-uploaded default image that appears until the user uploads their own. Tooltips can also be provided as text fields (String), files (File), or images (Image), offering additional context or visual instructions directly within the data entry interface. These features significantly enhance user convenience and ensure accurate and error-free data input.

Practical Example of Attribute Configuration

To better understand how Attribute Sets and their capabilities work in practice, let’s consider a real-world example. In the video below, we provide a step-by-step demonstration of setting up Attribute Sets for pages and products—from creating meta titles and descriptions to configuring product attributes such as images with placeholders, pricing, currency options, SKU validation with masks, quantity settings, and multi-select color lists accompanied by images.

📺 Watch the detailed video tutorial

Additionally, the example demonstrates how easy it is to rearrange the order of attributes, providing maximum convenience when working with your content.

Why It Matters

Using dynamic attribute sets in OneEntry allows you to rapidly adapt any entity without the need to modify database schemas or write additional code. This significantly speeds up development and makes content management more flexible.

The built-in validation system ensures data integrity directly at the user-interface level, minimizing errors and enhancing the overall user experience. Additionally, the ability to easily configure preview templates and placeholders optimizes resource usage and reduces page loading times, positively impacting the application’s perception by end-users.

Comparison with Other Market Solutions

Unlike OneEntry, other popular solutions often require additional configuration or custom coding to manage dynamic fields and validation effectively:

  • Strapi provides dynamic fields through dynamic zones, components, or plugins, but adding custom field types or advanced validations often requires creating additional plugins or writing custom code using Yup through lifecycle hooks.
  • Contentful, Shopify, and Payload do not offer built-in tools for image management, input masks, placeholders, or preview templates. These features typically must be implemented manually, using plugins or custom code.

By contrast, OneEntry offers all these capabilities right out of the box through an intuitive visual interface without plugins or additional programming required. This enables users to quickly, reliably, and conveniently configure content without unnecessary risks or costs associated with maintaining third-party components. OneEntry provides a complete, ready-to-use infrastructure for efficient attribute and validation management, simplifying tasks that other solutions typically require extensive customization and resources to achieve.

Conclusion and Further Resources

In this article, we’ve explored one of the key features of the OneEntry platform, designed to offer flexibility, simplify content management for non-technical team members, and maintain data integrity across your applications. Together, these benefits significantly enhance user experience, directly contributing to your business’s success and growth.

If you have additional questions or would like to explore the platform’s capabilities further, please consult our detailed documentation:

Additionally, you can test attribute configuration and validation firsthand using the Free license of the OneEntry platform.

🌐 OneEntry.cloud

Top comments (0)