Legality, in respect of an act, agreement, or contract is the state of being consistent with the law or of being lawful or unlawful in a given jurisdiction, and the construct of power.
According to the Merriam-Webster Dictionary, legality is 1 : attachment to or observance of law. 2 : the quality or state of being legal  Businessdictionary.com, thelawdictionary.org, and mylawdictionary.org definition explains concept of attachment to law as Implied warranty that an act, agreement, or contract strictly adheres to the statutes of a particular jurisdiction. For example, in insurance contracts it is assumed that all risks covered under the policy are legal ventures. The second definition cited by Businessdictionary.com, the Legal principle that an accused may not be prosecuted for an act that is not declared a crime in that jurisdiction is actually about the Principle of legality which is part of the overall concept of legality.
Vicki Schultz states that we collectively have a shared knowledge about most concepts. How we interpret the reality of our actual understanding of a concept manifests itself through the different individual narratives that we tell about the origins and meanings of a particular concept. The difference in narratives, about the same set of facts, is what divides us. An individual has the ability to frame, or understand, something very differently than the next person. Evidence does not always lead to a clear attribution of the specific cause or meaning of an issue - meanings are derived through narratives. Reality, and the facts that surround it, are personally subjective and laden with assumptions based on clearly stated facts. Anna-Maria Marshall states, this shift in framing happens because our perceptions depend "on new information and experiences;" this very idea is the basis of Ewick and Sibley definition of legality - our everyday experiences shape our understanding of the law.
Ewik and Silbey define "legality" more broadly as, those meanings, sources of authority, and cultural practices that are in some sense legal although not necessarily approved or acknowledged by official law. The concept of legality the opportunity to consider "how where and with what effect law is produced in and through commonplace social interactions....How do our roles and statuses our relationships, our obligations, prerogatives and responsibilities, our identities and our behavoiurs bear the imprint of law. 
In a paper on Normative Phenomena of Morality, Ethics and Legality, legality is defined taking the state's role in to account as, The system of laws and regulations of right and wrong behavior that are enforceable by the state (federal, state, or local governmental body in the U.S.) through the exercise of its policing powers and judicial process, with the threat and use of penalties, including its monopoly on the right to use physical violence.
Rule of law provides for availability of rules, laws and legal mechanism to implement them. Principle of legality checks for availability and quality of the laws. Legality checks for if certain behaviour is according to law or not. concept of Legitimacy of law looks for fairness or acceptability of fairness of process of implementation of law.
quality of being legal and observance to the law may pertain to lawfullness, i.e. being consistent to the law or it may get discussed in principle of legality or may be discussed as legal legitimacy.
In contract law, legality of purpose is required of every enforceable contract. One can not validate or enforce a contract to do activity with unlawful purpose.
The principle of legality can be affected in different ways by different constitutional models. In the United States, laws may not violate the stated provisions of the United States Constitution which includes a prohibition on retrospective laws. In Britain under the doctrine of Parliamentary sovereignty, the legislature can (in theory) pass such retrospective laws as it sees fit, though article 7 of the European convention on human rights, which has legal force in Britain, forbids conviction for a crime which was not illegal at the time it was committed. Article 7 has already had an effect in a number of cases in the British courts.
In contrast many written constitutions prohibit the creation of retroactive (normally criminal) laws. However the possibility of statutes being struck down creates its own problems. It is clearly more difficult to ascertain what is a valid statute when any number of statutes may have constitutional question marks hanging over them. When a statute is declared unconstitutional, the actions of public authorities and private individuals which were legal under the invalidated statute, are retrospectively tainted with illegality. Such a result could not occur under parliamentary sovereignty (or at least not before Factortame) as a statute was law and its validity could not be questioned in any court.
Legality, in its criminal aspect, is a principle of international human rights law, and is incorporated into the Universal Declaration of Human Rights, the International Covenant on Civil and Political Rights and the European Convention on Human Rights. However the imposition of penalties for offences illegal under international law or criminal according to "the general principles of law recognized by civilized nations" are normally excluded from its ambit. As such the trial and punishment for genocide, war crimes and crimes against humanity does not breach international law.
There is some debate about whether this is really a true exception or not. Some people would argue that it is a derogation or - perhaps somewhat more harshly - an infringement of the principle of legality. While others would argue that crimes such as genocide are contrary to natural law and as such are always illegal and always have been. Thus imposing punishment for them is always legitimate. The exception and the natural law justification for it can be seen as an attempt to justify the Nuremberg trials and the trial of Adolf Eichmann, both of which were criticized for applying retrospective criminal sanctions.
In criminal law, the principle of legality assures the primacy of law in all criminal proceedings.