CN107368530A - A kind of method and system based on custom properties checking data validity - Google Patents
A kind of method and system based on custom properties checking data validity Download PDFInfo
- Publication number
- CN107368530A CN107368530A CN201710446899.3A CN201710446899A CN107368530A CN 107368530 A CN107368530 A CN 107368530A CN 201710446899 A CN201710446899 A CN 201710446899A CN 107368530 A CN107368530 A CN 107368530A
- Authority
- CN
- China
- Prior art keywords
- data
- custom properties
- field
- checking
- entity
- 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
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
- G06F16/2365—Ensuring data consistency and integrity
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Storage Device Security (AREA)
Abstract
The present invention relates to a kind of method and system based on custom properties checking data validity, solution is to verify technical problem complicated, that efficiency is low, is encapsulated into by using by the logic of checking in custom properties, and certain field, which needs to verify, just adds this characteristic.During data check, only characteristic value need to be obtained to verify by reflecting, wherein the system includes being used for the data input cell for gathering input data;For storing the custom properties memory cell of custom properties, the custom properties are encapsulated by verifying logic and obtained;The central processor unit of entity, reflection and matching checking is defined for performing;For sending the data transmission unit of Validation of Data result;For the technical scheme of the record storage unit of record data checking history, the problem is preferably resolved, available in Validation of Data.
Description
Technical field
The present invention relates to human body behavior field of software development, and in particular to one kind is effective based on custom properties checking data
The method and system of property.
Background technology
In software development, in order to keep the integrality of data, it is necessary to carry out the twin check of client and service end, this
In introduce using custom properties complete servers' data verification, judge whether it effective.
The method of existing checking data validity is often to carry out a data and be required for providing single logic to go to verify.Bag
Include checking and judge whether it is sky, whether overlength, value meet particular requirement etc. to length.Existing checking data validity
In method, how many field is it is necessary to providing code as how many times;This can cause to write a large amount of same or analogous generations
Code, efficiency is low, stability is poor, redundancy, maintainable poor.Therefore it provides one kind is easy and effective, development efficiency is high, stability is high
Checking data validity method with regard to necessary.
The content of the invention
The technical problems to be solved by the invention are that technical problem complicated, that efficiency is low is verified present in prior art.
A kind of new method based on custom properties checking data validity is provided, should be based on custom properties checking data validity
Method have maintainable strong, method indirectly, efficiency high, high stability the characteristics of.
In order to solve the above technical problems, the technical scheme used is as follows:
A kind of method based on custom properties checking data validity, methods described include client verification and service end
Verification, the service end verification include verifying based on custom properties, and the custom properties verification includes:
(1) verifying logic is encapsulated as custom properties;
(2) define entity, the field of the field of entity and input data is consistent, be entity field in it is to be verified
Field sets custom properties value;
(3) input data is converted into the entity defined in step (2), the field of entity is obtained using reflection;Traversal is real
The field of body, the field value of entities field is obtained using reflection, custom properties corresponding to field to be verified are obtained using reflection
Value;
(4) field value that step (3) sphere obtains is converted into field type, field type and custom properties value is entered
Row contrast matching checking, the match is successful, then data are legal, data loading;It fails to match, then data are illegal, and returned data has
Effect property authentication failed signal.
The operation principle of the present invention:The present invention by custom properties, custom properties include the title of field, type,
Whether must fill out, the information such as length, selectable value.All field values of entity are got using reflection and field corresponds to self-defined spy
Property value;It is compared by field value with custom properties value, whether field is known that specifically by custom properties value
It must fill out, whether field value is empty, and whether overlength, field Value Types meet the requirements field length, final to verify that data have
Effect property.But regardless of how many field of entity, the substantial amounts of code of manual compiling is all no longer needed to go to verify data.By patrolling for checking
Collect and be encapsulated into characteristic, which field, which needs to verify, just adds this characteristic.During data check, only characteristic need to be obtained by reflecting
Value does verifying work.
In such scheme, for optimization, further, the service end verification also includes storage result detection, is put in storage successfully
Then returned data validation verification pass signal, be put in storage failure then returned data validation verification failure signal.
Further, the input data includes the data from service end page typing.
Further, the input data includes the data from third party's interface transmission.
Further, whether the custom properties include title, type, must fill out, length and enumerated value.
Further, the field type includes character string and numeral.
The present invention also provides a kind of system of the method based on custom properties checking data validity, the system bag
Include:
For gathering the data input cell of input data;
For storing the custom properties memory cell of custom properties, the custom properties encapsulated by verifying logic and
;
The central processor unit of entity, reflection and matching checking is defined for performing;
For sending the data transmission unit of Validation of Data result;
Record storage unit for record data checking history.
Further, the data verification historical record includes data verification proving time, checking number, the result.
In the present invention, entity refers to the example for mapping the class of a record in tables of data or view;In a class
Its property value is only defined, without doing other realizations.Reflection refers to a kind of computer processing mode.It is that program can be accessed, examined
Survey and change itself state or a kind of ability of behavior.
Beneficial effects of the present invention:
Effect one, by the way that the logic of checking is encapsulated into characteristic, which field, which needs to verify, just adds this characteristic, energy
The redundancy of enough optimization checking data validity methods, being capable of easy data verification method;
Effect two, verification efficiency is improved, verify stability;
Effect three, maintainable strong, method composition is succinct.
Brief description of the drawings
The present invention is further described with reference to the accompanying drawings and examples.
Fig. 1, the schematic flow sheet of data validity method is verified in embodiment 1 by custom properties.
Embodiment
In order to make the purpose , technical scheme and advantage of the present invention be clearer, with reference to embodiments, to the present invention
It is further elaborated.It should be appreciated that specific embodiment described herein is not used to limit only to explain the present invention
The fixed present invention.
Embodiment 1
The present embodiment provides a kind of method based on custom properties checking data validity, and methods described includes client
Verification and service end verification, such as Fig. 1, the service end verification include verifying based on custom properties, the custom properties school
Test including:
(1) verifying logic is encapsulated as custom properties;
(2) define entity, the field of the field of entity and input data is consistent, be entity field in it is to be verified
Field sets custom properties value;
(3) input data is converted into the entity defined in step (2), the field of entity is obtained using reflection;Traversal is real
The field of body, the field value of entities field is obtained using reflection, custom properties corresponding to field to be verified are obtained using reflection
Value;
(4) field value that step (3) sphere obtains is converted into field type, field type and custom properties value is entered
Row contrast matching checking, the match is successful, then data are legal, data loading;It fails to match, then data are illegal, and returned data has
Effect property authentication failed signal.
The workflow of the present embodiment:The present embodiment beam worker, which is put into effect, defines entity, is each word by custom properties
Segment identification title, type, length, whether must fill out, enumerated value.Input data will be received first, and the data of reception will be converted to pair
The entity answered, field value and corresponding custom properties value are obtained by reflecting, both are contrasted, carrying out data has
The checking of effect property.After being verified, by data loading, authentication failed, which is then put in storage, to fail, and will return to failure signal.
In the present embodiment, entity refers to the example for mapping the class of a record in tables of data or view;In a class
In only define its property value, without doing other realizations.
Reflection refers to a kind of computer processing mode.It is that program can access, detect and change itself state or behavior
A kind of ability.
Wherein, service end verification also includes storage result detection, be put in storage successfully then returned data validation verification into
Function signal, be put in storage failure then returned data validation verification failure signal.
Specifically, such as Fig. 1, the input data is included from the data of service end page typing or third party's interface transmission
Data.
Specifically, whether the custom properties include title, type, must fill out, length and enumerated value.
Specifically, the field type includes character string and numeral.
The present embodiment also provides a kind of system of the method based on custom properties checking data validity, the system bag
Include:
For gathering the data input cell of input data, the data input cell includes data receipt unit;
For storing the custom properties memory cell of custom properties, the custom properties encapsulated by verifying logic and
;
The central processor unit of entity, reflection and matching checking, i.e. CPU are defined for performing;
For sending the data transmission unit of Validation of Data result;
Record storage unit for record data checking history.
Wherein, data input cell collects input data for collection, in order to which input data is collected, data input cell
Including at least one data receipt unit, it can be reduced by multiple data receipt unit distributed receptions and receive error.
Data transmission unit, the present embodiment is using I2C buses as data transmission link.
Record storage unit, the present embodiment uses random access memory RAM as record storage, for store various types
Data and program.Random access memory RAM is the semiconductor memory that can read and can write-in.
Specifically, the data verification historical record includes data verification proving time, checking number, the result.This
Historical record in embodiment can pass through printer output by the service end page., being capable of convenient use by printer output
The effective observed data the result of person simultaneously consults statistics.
Although the illustrative embodiment of the present invention is described above, in order to the technology of the art
Personnel are it will be appreciated that the present invention, but the present invention is not limited only to the scope of embodiment, to the common skill of the art
For art personnel, as long as long as various change the present invention limit and determine spirit and scope in, all utilize structure of the present invention
The innovation and creation of think of are in the row of protection.
Claims (8)
1. a kind of method based on custom properties checking data validity, methods described include client verification and service end school
Test, it is characterised in that:The service end verification includes verifying based on custom properties, and the custom properties verification includes:
(1) verifying logic is encapsulated as custom properties;
(2) entity is defined, the field of the field of entity and input data is consistent, for field to be verified in the field of entity
Custom properties value is set;
(3) input data is converted into the entity defined in step (2), the field of entity is obtained using reflection;Travel through entity
Field, the field value of entities field is obtained using reflection, custom properties value corresponding to field to be verified is obtained using reflection;
(4) field value that step (3) sphere obtains is converted into field type, field type and custom properties value is carried out pair
Verified than matching;The match is successful, then data are legal, data loading;It fails to match, then data are illegal, returned data validity
Authentication failed signal.
2. the method according to claim 1 based on custom properties checking data validity, it is characterised in that:The clothes
End verification be engaged in also including storage result detection, is put in storage successfully then returned data validation verification pass signal, storage failure is then returned
Return Validation of Data failure signal.
3. the method according to claim 2 based on custom properties checking data validity, it is characterised in that:It is described defeated
Entering data includes the data from service end page typing.
4. the method according to claim 2 based on custom properties checking data validity, it is characterised in that:It is described defeated
Entering data includes the data from third party's interface transmission.
5. the method according to claim 2 based on custom properties checking data validity, it is characterised in that:It is described from
Whether defined property includes title, type, must fill out, length and enumerated value.
6. the method according to claim 2 based on custom properties checking data validity, it is characterised in that:The word
Segment type includes character string and numeral.
7. according to the system of any described methods that data validity is verified based on custom properties of claim 1-6, it is special
Sign is:The system includes:
For gathering the data input cell of input data;
For storing the custom properties memory cell of custom properties, the custom properties are encapsulated by verifying logic and obtained;
The central processor unit of entity, reflection and matching checking is defined for performing;
For sending the data transmission unit of Validation of Data result;
Record storage unit for record data checking history.
8. the system of the method according to claim 7 based on custom properties checking data validity, it is characterised in that:
The data verification historical record includes data verification proving time, checking number, the result.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710446899.3A CN107368530A (en) | 2017-06-14 | 2017-06-14 | A kind of method and system based on custom properties checking data validity |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710446899.3A CN107368530A (en) | 2017-06-14 | 2017-06-14 | A kind of method and system based on custom properties checking data validity |
Publications (1)
Publication Number | Publication Date |
---|---|
CN107368530A true CN107368530A (en) | 2017-11-21 |
Family
ID=60306419
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710446899.3A Pending CN107368530A (en) | 2017-06-14 | 2017-06-14 | A kind of method and system based on custom properties checking data validity |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107368530A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108228707A (en) * | 2017-11-27 | 2018-06-29 | 余姚市上易网络有限公司 | A kind of querying method of commodity historical price |
CN110209883A (en) * | 2019-06-06 | 2019-09-06 | 王慧斌 | A kind of method and device of user's history data validity judgement |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101753605A (en) * | 2008-12-02 | 2010-06-23 | 北大方正集团有限公司 | Data validation method and server |
CN102799690A (en) * | 2012-08-13 | 2012-11-28 | 南京莱斯信息技术股份有限公司 | Method for verifying page input by using database technology |
CN103106186A (en) * | 2013-01-22 | 2013-05-15 | 百度在线网络技术(北京)有限公司 | Form verification method and form verification system |
CN103246574A (en) * | 2012-02-10 | 2013-08-14 | 阿里巴巴集团控股有限公司 | Verification method and verification device for data accuracy |
CN103984547A (en) * | 2014-05-14 | 2014-08-13 | 上海上讯信息技术股份有限公司 | Form validation method and system |
-
2017
- 2017-06-14 CN CN201710446899.3A patent/CN107368530A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101753605A (en) * | 2008-12-02 | 2010-06-23 | 北大方正集团有限公司 | Data validation method and server |
CN103246574A (en) * | 2012-02-10 | 2013-08-14 | 阿里巴巴集团控股有限公司 | Verification method and verification device for data accuracy |
CN102799690A (en) * | 2012-08-13 | 2012-11-28 | 南京莱斯信息技术股份有限公司 | Method for verifying page input by using database technology |
CN103106186A (en) * | 2013-01-22 | 2013-05-15 | 百度在线网络技术(北京)有限公司 | Form verification method and form verification system |
CN103984547A (en) * | 2014-05-14 | 2014-08-13 | 上海上讯信息技术股份有限公司 | Form validation method and system |
Non-Patent Citations (1)
Title |
---|
黄玲: "《JavaEE程序设计及项目开发教程 JSP篇》", 31 January 2017, 重庆:重庆大学出版社 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108228707A (en) * | 2017-11-27 | 2018-06-29 | 余姚市上易网络有限公司 | A kind of querying method of commodity historical price |
CN110209883A (en) * | 2019-06-06 | 2019-09-06 | 王慧斌 | A kind of method and device of user's history data validity judgement |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8020074B2 (en) | Method for auto-correction of errors in a RAID memory system | |
CN107231337B (en) | Verification method and device applied to financial messages | |
US9575125B1 (en) | Memory device with reduced test time | |
CN102970282B (en) | website security detection system | |
CN106294222A (en) | A kind of method and device determining PCIE device and slot corresponding relation | |
CN106027528B (en) | A kind of method and device of the horizontal permission automatic identification of WEB | |
WO2019144548A1 (en) | Security test method, apparatus, computer device and storage medium | |
US10657028B2 (en) | Method for replicating production behaviours in a development environment | |
CN107124335A (en) | One kind is based on cloud sea operating system platform test method and system | |
CN102591773A (en) | Automatic evaluation method for operation system security in classified protection evaluation and system thereof | |
CN202736027U (en) | Automatic evaluation system for operation system security in classified protection evaluation | |
CN105791178A (en) | Message assembly method and device | |
CN107368530A (en) | A kind of method and system based on custom properties checking data validity | |
CN108733525A (en) | A kind of memory module tests and verifies the method and system of correctness automatically | |
CN104780123B (en) | A kind of network pack receiving and transmitting processing unit and its design method | |
CN107103243A (en) | The detection method and device of leak | |
CN110399304A (en) | A kind of test method and system of script | |
CN113626421A (en) | Data quality control method for data verification | |
CN107562565A (en) | A kind of method for verifying internal memory Patrol Scurb functions | |
CN107798540A (en) | Risk control method, system, storage medium and the electronic equipment that order is paid | |
CN111897833A (en) | Data processing method and device | |
CN116501536A (en) | AXI interconnection module checking, checking and protecting method, device and storage medium | |
CN114338850B (en) | Message checking method, device, terminal equipment and computer readable storage medium | |
CN110688823A (en) | XML file verification method and device | |
CN105426183A (en) | Form verification method |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20171121 |
|
RJ01 | Rejection of invention patent application after publication |