CN117910052A - Method and system for verifying data integrity and correctness - Google Patents

Method and system for verifying data integrity and correctness Download PDF

Info

Publication number
CN117910052A
CN117910052A CN202311779333.4A CN202311779333A CN117910052A CN 117910052 A CN117910052 A CN 117910052A CN 202311779333 A CN202311779333 A CN 202311779333A CN 117910052 A CN117910052 A CN 117910052A
Authority
CN
China
Prior art keywords
verification
data
target data
verifying
map
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311779333.4A
Other languages
Chinese (zh)
Inventor
郜辉辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangxin Yunxiang Technology Co ltd
Original Assignee
Hangxin Yunxiang Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangxin Yunxiang Technology Co ltd filed Critical Hangxin Yunxiang Technology Co ltd
Priority to CN202311779333.4A priority Critical patent/CN117910052A/en
Publication of CN117910052A publication Critical patent/CN117910052A/en
Pending legal-status Critical Current

Links

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a method and a system for verifying the integrity and correctness of data, wherein the method comprises the following steps: when receiving or transmitting target data to be verified, converting the target data into map set type data; establishing a verification template comprising a combination of multiple verification methods; verifying the target data of the map set type data based on the verification template; and acquiring a verification result of the target data and outputting the verification result. The data verification execution of the invention does not depend on a third party code library, and has high adaptability; the invention has no complex and useless code flow, high code execution efficiency and high speed; the invention has the advantages of self-defining combination verification template, self-defining abnormality, high flexibility and wide application range.

Description

Method and system for verifying data integrity and correctness
Technical Field
The present invention relates to the field of information technology application technology, and more particularly, to a method and system for verifying data integrity and correctness.
Background
Data validation plays a vital role in the analysis and processing of data in each system. First, it can check the accuracy of the data collected or transmitted to, ensuring the correctness of all the information. In tasks such as data analysis and data transmission, data quality is a central factor. If there is an error, miss or inconsistency in the data, this will lead to inaccuracy and misleading of the analysis results and stored data. Furthermore, data integrity is also critical, focusing on the accuracy, reliability and validity of data throughout the life cycle. Doubt and verification of data is a necessary principle for each program because the probability of data errors is high. Therefore, the data should first be tightly verified to ensure the quality and integrity of the data before any data reception or transmission takes place.
In the system development process, the rear end receives the form data, and the cross-system message transmission and reception, excel data importing and other services all need to verify the integrity and the correctness of the data. The integrity and correctness of the data is verified very frequently during the system development process.
Therefore, a technique is needed to achieve verification of data integrity and correctness.
Disclosure of Invention
The technical scheme of the invention provides a method and a system for verifying the data integrity and the correctness, so as to solve the problem of how to verify the data integrity and the correctness.
In order to solve the above problems, the present invention provides a method for verifying data integrity and correctness, the method comprising:
when receiving or transmitting target data to be verified, converting the target data into map set type data;
Establishing a verification template comprising a combination of multiple verification methods;
Verifying the target data of the map set type data based on the verification template;
and acquiring a verification result of the target data and outputting the verification result.
Preferably, the types of the target data include: form data, cross-system message data.
Preferably, the verification template is stored in: files, relational databases, non-relational databases, and code classes.
Preferably, the verifying the target data of the map aggregate type data based on the verification template includes verifying validity of the target data:
verifying whether the target data conforms to an expected format and range.
Preferably, the verifying the target data of the map set type data based on the verification template includes verifying a value in a map object of the map set type data:
Traversing a rule array in the verification template, and extracting key names, value types and error messages through the rule array based on each rule; when the field which cannot be extracted exists, setting the field which cannot be extracted as an empty character string;
When the empty character string does not exist, acquiring a value corresponding to the key name based on a map object in map set type data;
and verifying whether the value corresponding to the key name accords with the designated value type.
Preferably, the verifying the target data of the map set type data based on the verification template includes verifying whether the input character string meets a rule:
The verification template stores a regular expression pattern and a matcher object, and a list containing verification rules is obtained;
and traversing the list circularly, and verifying each rule.
Based on another aspect of the present invention, the present invention provides a system for verifying data integrity and correctness, the system comprising:
The device comprises an initial unit, a verification unit and a verification unit, wherein the initial unit is used for converting target data to map set type data when receiving or transmitting the target data to be verified;
A building unit for building a verification template including a combination of a plurality of verification methods;
the verification unit is used for verifying the target data of the map set type data based on the verification template;
And the result unit is used for acquiring the verification result of the target data and outputting the verification result.
Preferably, the types of the target data include: form data, cross-system message data.
Preferably, the verification template is stored in: files, relational databases, non-relational databases, and code classes.
Preferably, the verification unit is configured to verify, based on the verification template, target data of map set type data, and is further configured to verify validity of the target data:
verifying whether the target data conforms to an expected format and range.
Preferably, the verification unit is configured to verify target data of the map set type data based on the verification template, and is further configured to verify a value in a map object of the map set type data:
Traversing a rule array in the verification template, and extracting key names, value types and error messages through the rule array based on each rule; when the field which cannot be extracted exists, setting the field which cannot be extracted as an empty character string;
When the empty character string does not exist, acquiring a value corresponding to the key name based on a map object in map set type data;
and verifying whether the value corresponding to the key name accords with the designated value type.
Preferably, the verification unit is configured to verify, based on the verification template, target data of map set type data, including verifying whether an input character string meets a rule:
The verification template stores a regular expression pattern and a matcher object, and a list containing verification rules is obtained;
and traversing the list circularly, and verifying each rule.
The technical scheme of the invention provides a method and a system for verifying the integrity and the correctness of data, wherein the method comprises the following steps: when receiving or transmitting target data to be verified, converting the target data into map set type data; establishing a verification template comprising a combination of multiple verification methods; verifying the target data of the map set type data based on the verification template; and acquiring a verification result of the target data, and outputting the verification result. The technical scheme of the invention provides a set of data verification method and system based on JAVA language, which can efficiently and safely finish data verification and ensure the integrity and the correctness of data.
Drawings
Exemplary embodiments of the present invention may be more completely understood in consideration of the following drawings:
FIG. 1 is a flow chart of a method of verifying data integrity and correctness in accordance with a preferred embodiment of the present invention;
FIG. 2 is a flow chart of a method of verifying data integrity and correctness in accordance with a preferred embodiment of the present invention; and
Fig. 3 is a system configuration diagram for verifying data integrity and correctness according to a preferred embodiment of the present invention.
Detailed Description
The exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, however, the present invention may be embodied in many different forms and is not limited to the examples described herein, which are provided to fully and completely disclose the present invention and fully convey the scope of the invention to those skilled in the art. The terminology used in the exemplary embodiments illustrated in the accompanying drawings is not intended to be limiting of the invention. In the drawings, like elements/components are referred to by like reference numerals.
Unless otherwise indicated, terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art. In addition, it will be understood that terms defined in commonly used dictionaries should be interpreted as having a meaning that is consistent with their meaning in the context of the relevant art and will not be interpreted in an idealized or overly formal sense.
FIG. 1 is a flow chart of a method for verifying data integrity and correctness according to a preferred embodiment of the present invention.
The invention is operated in various functional modules of a plurality of systems, and is applied to the business such as form data receiving at the rear end, cross-system message transmission and receiving, excel data importing and the like for a plurality of times.
The invention uses a definable combination verification method, and can carry out combination verification by a self-defined verification function, a regular expression, a third party verification framework and the like.
The present invention can be used without a third frame.
The invention relates to a verification template, verification execution and abnormal output module.
The operation steps of the invention mainly comprise:
Receiving or transmitting data
Converting data to map set type
Acquiring verification templates
Execution data verification module
Returning the verification result
As shown in fig. 1, the present invention provides a method for verifying the integrity and correctness of data, the method comprising:
Step 101: when receiving or transmitting target data to be verified, converting the target data into map set type data;
Preferably, the types of the target data include: form data, cross-system message data.
Step 102: establishing a verification template comprising a combination of multiple verification methods;
Preferably, the verification template is stored in: files, relational databases, non-relational databases, and code classes.
The verification template of the invention can be stored in files, relational databases, non-relational databases, code classes and the like; the verification templates are combined by using a two-dimensional array, and the storage and combination methods are various: the following examples are one type of data format in a code class.
Step 103: verifying the target data of the map set type data based on the verification template;
Step 104: and acquiring a verification result of the target data, and outputting the verification result.
Preferably, verifying the target data of the map aggregate type data based on the verification template includes verifying validity of the target data:
And verifying whether the target data accords with the expected format and range.
Preferably, verifying the target data of the map set type data based on the verification template includes verifying values in a map object of the map set type data:
Traversing a rule array in the verification template, and extracting key names, value types and error messages through the rule array based on each rule; when the field which cannot be extracted exists, setting the field which cannot be extracted as an empty character string;
when the empty character string does not exist, acquiring a value corresponding to the key name based on the map object in the map set type data;
And verifying whether the value corresponding to the key name accords with the designated value type.
Preferably, verifying the target data of the map set type data based on the verification template includes verifying whether the input character string meets the rule:
The verification template stores the regular expression pattern and the matcher object, and a list containing verification rules is obtained;
and (5) circularly traversing the list and verifying each rule.
Description of codes:
The code is a two-dimensional string array named REMKO _RULE. It contains rules for verifying the legitimacy of the input data. Each element is a string array comprising three parts:
Field names (e.g. "bizcode", "einvoicecode", etc.)
Verification rules (e.g. "required; RANGELENGTH:1,32", "nString", etc.)
Error prompt (e.g. "serial number error", "invalid character string", etc.)
These rules can be used to verify the input data in the program, ensuring that they conform to the expected format and scope. If the value of a certain field does not accord with the rule, the program returns corresponding error prompt information.
And executing a verification module:
description of codes: this code is a verification method, named validate, for checking whether a given Map object meets a specified rule. It accepts two parameters: a Map object (Map) and a two-dimensional string array (rule).
The method first traverses the rule array, which attempts to extract key names, value types, and error messages from the rule array for each rule. If a field cannot be extracted, it is set as an empty string.
Then, if neither the key name nor the value type is null, it will acquire the value corresponding to the key name from the Map object using the collectionUtil. Next, it invokes VALIDATEING () method to verify whether the value meets the specified value type. If not, the provided error message is used for prompting.
The main function of this approach is to verify the values in Map objects, ensuring that they conform to the expected data type and format.
/>
/>
/>
/>
/>
/>
/>
/>
Description of codes: this code is a Java method for verifying whether the input string meets a specific rule. The method is named VALIDATEING, and four parameters are received: mapValue (string value requiring verification), keyName (key name associated with error message), vtype (verification type) and msg (error message).
The method first defines two variables pattern and mat, which are used for storing regular expression patterns and matcher objects respectively. Then, a list containing validation rules is obtained by calling GETRSPMSG methods. Next, each rule is processed using a for loop through this list.
For example, it is first determined whether the rule is "required" or mapValue is empty, and if the condition is satisfied, a ValidationException exception is thrown with a corresponding error message.
Next, validation is performed according to different rules using switch statements. If the rule is "email," then check mapValue if it matches the regular expression of email; if "URL," compiling a regular expression of the URL and attempting to match mapValue; and so on. If a rule does not match, a ValidationException exception is thrown with a corresponding error message.
Finally, if all rules pass verification, the method will end normally.
Description of codes: this code is a Java method, named GETRSPMSG, which accepts a string parameter vtype and returns a list of strings. The method has the main functions of dividing the input character string according to a division number (the number of the character string), and adding the divided sub-character strings into a list. If the input string is empty or contains empty substrings, then a ValidationException exception is thrown.
Description of codes: this code is a Java method called getTypeErrorMsg. It accepts two string parameters: keyName and rule. The method is used for generating an error message according to the given keyName and rule, and the error message is used for indicating that a certain check rule does not exist or the use mode is wrong.
The method firstly creates StringBuffer object sb, and then adds the content information to be prompted into the sb in turn by calling the application method. Finally, the sb is converted into a string by calling toString methods and returned.
/>
Description of codes: this code is a Java method called GETRSPMSG. It accepts three string parameters: keyName, rule, and msg. According to the rule value, the method performs different operations and returns a spliced character string.
Specifically, if the rule value is "required", it is checked whether msg is empty. If MSG is empty, MSG is set to ISEMPTY _MSG (a constant). Otherwise, no operation is performed.
If the value of rule is not "required", it is also checked whether msg is empty. If MSG is empty, MSG is set to common_msg (another constant). Otherwise, no operation is performed.
Finally, keyName and msg are stitched together as return values.
An anomaly module:
/>
description of codes: this is a Java class named ValidationException, which inherits from RuntimeException. This class has four constructors:
Non-parametric constructors: a ValidationException instance is created without a message.
Constructors with string parameters: a ValidationException instance is created with a specified message.
Constructors with string parameters and Throwable parameters: a ValidationException instance is created with the specified message and cause.
Constructors with Throwable parameters: an instance ValidationException is created with the specified cause.
This class is used to represent anomalies that occur during the verification process.
The data verification execution of the invention does not depend on a third party code library, and has high adaptability; the invention has no complex and useless code flow, high code execution efficiency and high speed; the invention has the advantages of self-defining the combined template, self-defining abnormality, high flexibility and wide application range.
The invention effectively solves the corresponding business problem in the system, simplifies the data verification code, greatly improves the development efficiency of the developer, saves a great amount of manual working hours of the developer, has high data verification processing speed, high accuracy, saves time and resources, and has wide business application range.
Fig. 3 is a system configuration diagram for verifying data integrity and correctness according to a preferred embodiment of the present invention.
As shown in fig. 3, the present invention provides a system for verifying data integrity and correctness, the system comprising:
An initial unit 301, configured to convert target data into map set type data when receiving or transmitting target data to be verified;
Preferably, the types of the target data include: form data, cross-system message data.
A building unit 302 for building a verification template comprising a combination of multiple verification methods;
Preferably, the verification template is stored in: files, relational databases, non-relational databases, and code classes.
A verification unit 303, configured to verify the target data of the map aggregate type data based on the verification template;
and a result unit 304, configured to obtain a verification result of the target data, and output the verification result.
Preferably, the verification unit 303 is configured to verify, based on a verification template, the target data of the map aggregate type data, and is further configured to verify validity of the target data:
And verifying whether the target data accords with the expected format and range.
Preferably, the verification unit 303 is configured to verify target data of the map set type data based on a verification template, and is further configured to verify a value in a map object of the map set type data:
Traversing a rule array in the verification template, and extracting key names, value types and error messages through the rule array based on each rule; when the field which cannot be extracted exists, setting the field which cannot be extracted as an empty character string;
when the empty character string does not exist, acquiring a value corresponding to the key name based on the map object in the map set type data;
And verifying whether the value corresponding to the key name accords with the designated value type.
Preferably, the verification unit 303 is configured to verify, based on a verification template, the target data of the map set type data, including verifying whether the input character string meets a rule:
The verification template stores the regular expression pattern and the matcher object, and a list containing verification rules is obtained;
and (5) circularly traversing the list and verifying each rule.
A system for verifying data integrity and correctness according to a preferred embodiment of the present invention corresponds to a method for verifying data integrity and correctness according to a preferred embodiment of the present invention, and will not be described in detail herein.
It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein. The scheme in the embodiment of the invention can be realized by adopting various computer languages, such as object-oriented programming language Java, an transliteration script language JavaScript and the like.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present invention without departing from the spirit or scope of the invention. Thus, it is intended that the present invention also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.
The invention has been described with reference to a few embodiments. However, as is well known to those skilled in the art, other embodiments than the above disclosed invention are equally possible within the scope of the invention, as defined by the appended patent claims.
Generally, all terms used in the claims are to be interpreted according to their ordinary meaning in the technical field, unless explicitly defined otherwise therein. All references to "a/an/the [ means, component, etc. ]" are to be interpreted openly as referring to at least one instance of said means, component, etc., unless explicitly stated otherwise. The steps of any method disclosed herein do not have to be performed in the exact order disclosed, unless explicitly stated.

Claims (12)

1. A method of verifying data integrity and correctness, the method comprising:
when receiving or transmitting target data to be verified, converting the target data into map set type data;
Establishing a verification template comprising a combination of multiple verification methods;
Verifying the target data of the map set type data based on the verification template;
and acquiring a verification result of the target data and outputting the verification result.
2. The method of claim 1, the type of target data comprising: form data, cross-system message data.
3. The method of claim 1, the verification template stored in: files, relational databases, non-relational databases, and code classes.
4. The method of claim 1, the verifying the target data of the map aggregate type data based on the verification template, comprising verifying validity of the target data:
verifying whether the target data conforms to an expected format and range.
5. The method of claim 1, the validating target data of the map-set type data based on the validation template comprising validating values in a map object of the map-set type data:
Traversing a rule array in the verification template, and extracting key names, value types and error messages through the rule array based on each rule; when the field which cannot be extracted exists, setting the field which cannot be extracted as an empty character string;
When the empty character string does not exist, acquiring a value corresponding to the key name based on a map object in map set type data;
and verifying whether the value corresponding to the key name accords with the designated value type.
6. The method of claim 1, wherein verifying the target data of the map set type data based on the verification template includes verifying whether the input character string meets a rule:
The verification template stores a regular expression pattern and a matcher object, and a list containing verification rules is obtained;
and traversing the list circularly, and verifying each rule.
7. A system for verifying data integrity and correctness, the system comprising:
The device comprises an initial unit, a verification unit and a verification unit, wherein the initial unit is used for converting target data to map set type data when receiving or transmitting the target data to be verified;
A building unit for building a verification template including a combination of a plurality of verification methods;
the verification unit is used for verifying the target data of the map set type data based on the verification template;
And the result unit is used for acquiring the verification result of the target data and outputting the verification result.
8. The system of claim 7, the type of target data comprising: form data, cross-system message data.
9. The system of claim 7, the verification template stored in: files, relational databases, non-relational databases, and code classes.
10. The system according to claim 7, the verification unit is configured to verify target data of map set type data based on the verification template, and is further configured to verify validity of the target data:
verifying whether the target data conforms to an expected format and range.
11. The system of claim 7, the verification unit to verify target data of the map aggregate type data based on the verification template, and to verify values in a map object of the map aggregate type data:
Traversing a rule array in the verification template, and extracting key names, value types and error messages through the rule array based on each rule; when the field which cannot be extracted exists, setting the field which cannot be extracted as an empty character string;
When the empty character string does not exist, acquiring a value corresponding to the key name based on a map object in map set type data;
and verifying whether the value corresponding to the key name accords with the designated value type.
12. The system according to claim 7, the verification unit configured to verify target data of map set type data based on the verification template, including verifying whether an input character string meets a rule:
The verification template stores a regular expression pattern and a matcher object, and a list containing verification rules is obtained;
and traversing the list circularly, and verifying each rule.
CN202311779333.4A 2023-12-22 2023-12-22 Method and system for verifying data integrity and correctness Pending CN117910052A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311779333.4A CN117910052A (en) 2023-12-22 2023-12-22 Method and system for verifying data integrity and correctness

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311779333.4A CN117910052A (en) 2023-12-22 2023-12-22 Method and system for verifying data integrity and correctness

Publications (1)

Publication Number Publication Date
CN117910052A true CN117910052A (en) 2024-04-19

Family

ID=90681047

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311779333.4A Pending CN117910052A (en) 2023-12-22 2023-12-22 Method and system for verifying data integrity and correctness

Country Status (1)

Country Link
CN (1) CN117910052A (en)

Similar Documents

Publication Publication Date Title
CN108196878B (en) Method and device for generating application program installation package, electronic equipment and storage medium
CN111258900A (en) Interface test script generation method, system, equipment and storage medium
WO2019112568A1 (en) Inductive equivalence in machine-based instruction editing
CN105607923A (en) Cross-platform avionics system configuration data generation and recovery method
CN109725906A (en) A kind of code compiling method and corresponding continuous integration system
CN111459509A (en) Container mirror image construction method and device and server
CN104598619A (en) Service compositional verification method based on constraint solver
KR102226463B1 (en) UI/UX solution providing server linked with process automation program, process automation method using the same, and computer program executing the same
CN113377667A (en) Scene-based testing method and device, computer equipment and storage medium
CN112817935A (en) Data processing method, device and equipment based on field type and storage medium
CN111782526A (en) Interface testing method and device, electronic equipment and storage medium
CN107193249B (en) Program development support device and program development support method
CN117910052A (en) Method and system for verifying data integrity and correctness
JP2008305079A (en) Requirement specification automatic verification method
CN111338940A (en) Code processing method, device and system
CN115904317A (en) Method, device, equipment and storage medium for uniformly calling front-end interface and back-end interface
CN115599394A (en) Serialization and deserialization method, device, computer equipment and storage medium
CN112214415B (en) Trusted management method for executable files of airborne embedded system
CN112882707B (en) Rendering method and device, storage medium and electronic equipment
US20130042224A1 (en) Application analysis device
Ribeiro Large Language Models for Automated Program Repair
CN114356680A (en) Verification method and device and electronic equipment
CN114531289A (en) System interaction method based on artificial intelligence and related equipment
KR101731629B1 (en) Method and device for automatic generating go code from circus
CN114756217B (en) Plug-in based script generation system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination