@@ -543,19 +543,38 @@ LIBYANG_API_DECL typedef void (*lyplg_type_lyb_size_clb)(const struct lysc_type
543543 * @param[out] err Optionally provided error information in case of failure. If not provided to the caller, a generic
544544 * error message is prepared instead. The error structure can be created by ::ly_err_new().
545545 * @return LY_SUCCESS on success,
546- * @return LY_EINCOMPLETE in case the ::lyplg_type_validate_clb should be called to finish value validation in data,
546+ * @return LY_EINCOMPLETE in case the ::lyplg_type_validate_tree_clb is defined and should be called to finish value
547+ * validation in data,
547548 * @return LY_ERR value on error, @p storage must not have any pointers to dynamic memory.
548549 */
549550LIBYANG_API_DECL typedef LY_ERR (* lyplg_type_store_clb )(const struct ly_ctx * ctx , const struct lysc_type * type ,
550551 const void * value , uint32_t value_size_bits , uint32_t options , LY_VALUE_FORMAT format , void * prefix_data , uint32_t hints ,
551552 const struct lysc_node * ctx_node , const struct lysc_ext_instance * top_ext , struct lyd_value * storage ,
552553 struct lys_glob_unres * unres , struct ly_err_item * * err );
553554
555+ /**
556+ * @brief Callback to validate the stored value local semantic constraints of the type.
557+ *
558+ * This callback should perform any required validation of the value after it is stored. If the stored value is always
559+ * valid disregarding the accessible data tree, this callback should not be defined (but ::lyplg_type_validate_tree()
560+ * may be).
561+ *
562+ * @param[in] ctx libyang context.
563+ * @param[in] type Original type of the value (not necessarily the stored one) being validated.
564+ * @param[in,out] storage Storage of the value successfully filled by ::lyplg_type_store_clb. May be modified.
565+ * @param[out] err Optionally provided error information in case of failure. If not provided to the caller, a generic
566+ * error message is prepared instead. The error structure can be created by ::ly_err_new().
567+ * @return LY_SUCCESS on success,
568+ * @return LY_ERR value on error.
569+ */
570+ LIBYANG_API_DECL typedef LY_ERR (* lyplg_type_validate_value_clb )(const struct ly_ctx * ctx , const struct lysc_type * type ,
571+ struct lyd_value * storage , struct ly_err_item * * err );
572+
554573/**
555574 * @brief Callback to validate the stored value in the accessible data tree.
556575 *
557- * This callback is optional and may not be defined for types that do not require the accessible data tree for
558- * validation (::lyplg_type_store_clb fully stores and validates the value) .
576+ * This callback should perform any final validation that depends on the other data nodes in the accessible tree. If
577+ * the other nodes do not affect the validity of this value, this callback should not be defined .
559578 *
560579 * @param[in] ctx libyang context.
561580 * @param[in] type Original type of the value (not necessarily the stored one) being validated.
@@ -568,7 +587,7 @@ LIBYANG_API_DECL typedef LY_ERR (*lyplg_type_store_clb)(const struct ly_ctx *ctx
568587 * @return LY_SUCCESS on success,
569588 * @return LY_ERR value on error.
570589 */
571- LIBYANG_API_DECL typedef LY_ERR (* lyplg_type_validate_clb )(const struct ly_ctx * ctx , const struct lysc_type * type ,
590+ LIBYANG_API_DECL typedef LY_ERR (* lyplg_type_validate_tree_clb )(const struct ly_ctx * ctx , const struct lysc_type * type ,
572591 const struct lyd_node * ctx_node , const struct lyd_node * tree , const struct lysc_ext_instance * top_ext ,
573592 struct lyd_value * storage , struct ly_err_item * * err );
574593
@@ -660,7 +679,8 @@ struct lyplg_type {
660679 const char * id ; /**< Plugin name id, can be used for distinguishing incompatible versions. */
661680 lyplg_type_lyb_size_clb lyb_size ; /**< Size of the value in [LYB format](@ref howtoDataLYB) in bits. */
662681 lyplg_type_store_clb store ; /**< Storing and canonization callback for the value. */
663- lyplg_type_validate_clb validate ; /**< Optional validation callback that can use the accessible data tree. */
682+ lyplg_type_validate_value_clb validate_value ; /**< Optional value validation callback. */
683+ lyplg_type_validate_tree_clb validate_tree ; /**< Optional data tree value validation callback. */
664684 lyplg_type_compare_clb compare ; /**< Comparison callback for comparing 2 values of the same type. */
665685 lyplg_type_sort_clb sort ; /**< Comparison callback for sorting values. */
666686 lyplg_type_print_clb print ; /**< Printer callback for getting value representation in any format. */
@@ -747,6 +767,12 @@ LIBYANG_API_DECL LY_ERR lyplg_type_store_string(const struct ly_ctx *ctx, const
747767 const struct lysc_node * ctx_node , const struct lysc_ext_instance * top_ext , struct lyd_value * storage ,
748768 struct lys_glob_unres * unres , struct ly_err_item * * err );
749769
770+ /**
771+ * @brief Implementation of ::lyplg_type_validate_value_clb for the string type.
772+ */
773+ LIBYANG_API_DECL LY_ERR lyplg_type_validate_value_string (const struct ly_ctx * ctx , const struct lysc_type * type ,
774+ struct lyd_value * storage , struct ly_err_item * * err );
775+
750776/**
751777 * @brief Implementation of ::lyplg_type_print_clb for the ietf-yang-types xpath1.0 type.
752778 */
0 commit comments