A County Antrim school's uniform policy did not sexually discriminate against boys, the High Court has ruled.
The judge said Grant Stranaghan should not have been segregated
Ballyclare High School does not allow pupils to grow their hair to a length that reaches their blazer collars.
Grant Stranaghan, 16, was suspended and then segregated from other pupils because he would not cut his hair.
Mr Justice Weatherup said Grant's human rights had not been breached, but ruled he should have been put on detention rather than segregated.
The judge said segregation "was not part of the disciplinary policy".
He said "a lesser sanction should have been used" upon the GCSE student's return to Ballyclare High after his suspension.
The school had gone to the High Court seeking confirmation that its uniform and disciplinary policies were lawful after the haircut row intensified.
The judge said he would be making the declaration sought stressing that it "may be considered heavy-handed given the escalating issues in the case".
A court ruling had prevented the naming of the schoolboy, but Grant and his father George waived their right to anonymity.
Lawyers for the 16-year-old and another pupil disciplined for the length of his hair had contested the action, with Children's Commission Patricia Lewsley also brought in to give her opinion.
However, after a three-day judicial review hearing, the judge said he was satisfied that the school code was not unlawful.
In a statement the school said: "We are obviously pleased that the judge has decided that our code of conduct, including our uniform code, is lawful.
"This is an important decision not just for Ballyclare High School but for all other schools and organisation which operate a uniform code and will no doubt be of great interest and relief to them."